Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Cleanup files after upload on native (#3597)

* cleanup images after uploading from the composer

cleanup external embed images as well

cleanup files after upload

add `expo-file-system`

* remove test log

* await

* Revert "await"

This reverts commit 771814b40ce1395cac4f56853d8a9e793ca92c2f.

* just log an error if it throws

authored by

Hailey and committed by
GitHub
410f1559 a2df8141

+31 -6
+1
package.json
··· 116 116 "expo-constants": "~15.4.5", 117 117 "expo-dev-client": "~3.3.8", 118 118 "expo-device": "~5.9.3", 119 + "expo-file-system": "^16.0.9", 119 120 "expo-haptics": "^12.8.1", 120 121 "expo-image": "~1.10.6", 121 122 "expo-image-manipulator": "^11.8.0",
+25 -6
src/lib/api/index.ts
··· 1 + import {deleteAsync} from 'expo-file-system' 1 2 import { 3 + AppBskyEmbedExternal, 2 4 AppBskyEmbedImages, 3 - AppBskyEmbedExternal, 4 5 AppBskyEmbedRecord, 5 6 AppBskyEmbedRecordWithMedia, 6 7 AppBskyFeedThreadgate, ··· 11 12 RichText, 12 13 } from '@atproto/api' 13 14 import {AtUri} from '@atproto/api' 14 - import {isNetworkError} from 'lib/strings/errors' 15 - import {LinkMeta} from '../link-meta/link-meta' 16 - import {isWeb} from 'platform/detection' 17 - import {ImageModel} from 'state/models/media/image' 18 - import {shortenLinks} from 'lib/strings/rich-text-manip' 15 + 19 16 import {logger} from '#/logger' 20 17 import {ThreadgateSetting} from '#/state/queries/threadgate' 18 + import {isNetworkError} from 'lib/strings/errors' 19 + import {shortenLinks} from 'lib/strings/rich-text-manip' 20 + import {isNative, isWeb} from 'platform/detection' 21 + import {ImageModel} from 'state/models/media/image' 22 + import {LinkMeta} from '../link-meta/link-meta' 21 23 22 24 export interface ExternalEmbedDraft { 23 25 uri: string ··· 117 119 const {width, height} = image.compressed || image 118 120 logger.debug(`Uploading image`) 119 121 const res = await uploadBlob(agent, path, 'image/jpeg') 122 + 123 + if (isNative) { 124 + try { 125 + deleteAsync(path) 126 + } catch (e) { 127 + console.error(e) 128 + } 129 + } 130 + 120 131 images.push({ 121 132 image: res.data.blob, 122 133 alt: image.altText ?? '', ··· 171 182 encoding, 172 183 ) 173 184 thumb = thumbUploadRes.data.blob 185 + 186 + try { 187 + if (isNative) { 188 + deleteAsync(opts.extLink.localThumb.path) 189 + } 190 + } catch (e) { 191 + console.error(e) 192 + } 174 193 } 175 194 } 176 195
+5
yarn.lock
··· 11852 11852 resolved "https://registry.yarnpkg.com/expo-eas-client/-/expo-eas-client-0.11.0.tgz#0f25aa497849cade7ebef55c0631093a87e58b07" 11853 11853 integrity sha512-99W0MUGe3U4/MY1E9UeJ4uKNI39mN8/sOGA0Le8XC47MTbwbLoVegHR3C5y2fXLwLn7EpfNxAn5nlxYjY3gD2A== 11854 11854 11855 + expo-file-system@^16.0.9: 11856 + version "16.0.9" 11857 + resolved "https://registry.yarnpkg.com/expo-file-system/-/expo-file-system-16.0.9.tgz#cbd6c4b228b60a6b6c71fd1b91fe57299fb24da7" 11858 + integrity sha512-3gRPvKVv7/Y7AdD9eHMIdfg5YbUn2zbwKofjsloTI5sEC57SLUFJtbLvUCz9Pk63DaSQ7WIE1JM0EASyvuPbuw== 11859 + 11855 11860 expo-file-system@~16.0.0: 11856 11861 version "16.0.1" 11857 11862 resolved "https://registry.yarnpkg.com/expo-file-system/-/expo-file-system-16.0.1.tgz#326b7c2f6e53e1a0eaafc9769578aafb3f9c9f43"