···73737474 try {
7575 await saveImageToMediaLibrary({uri: imageUrl})
7676- Toast.show(_(msg`Image saved to your camera roll!`))
7676+ Toast.show(_(msg`Image saved`))
7777 control.close()
7878 } catch (e: unknown) {
7979 Toast.show(_(msg`An error occurred while saving the QR code!`), 'xmark')
+30-2
src/lib/media/manip.ts
···126126 safeDeleteAsync(imagePath)
127127}
128128129129+const ALBUM_NAME = 'Bluesky'
130130+129131export async function saveImageToMediaLibrary({uri}: {uri: string}) {
130132 // download the file to cache
131133 // NOTE
···139141 imagePath = normalizePath(await moveToPermanentPath(imagePath, '.png'), true)
140142141143 // save
142142- await MediaLibrary.createAssetAsync(imagePath)
143143- safeDeleteAsync(imagePath)
144144+ try {
145145+ if (isAndroid) {
146146+ // android triggers an annoying permission prompt if you try and move an image
147147+ // between albums. therefore, we need to either create the album with the image
148148+ // as the starting image, or put it directly into the album
149149+ const album = await MediaLibrary.getAlbumAsync(ALBUM_NAME)
150150+ if (album) {
151151+ // if album exists, put the image straight in there
152152+ await MediaLibrary.createAssetAsync(imagePath, album)
153153+ } else {
154154+ // otherwise, create album with asset (albums must always have at least one asset)
155155+ await MediaLibrary.createAlbumAsync(
156156+ ALBUM_NAME,
157157+ undefined,
158158+ undefined,
159159+ imagePath,
160160+ )
161161+ }
162162+ } else {
163163+ await MediaLibrary.createAssetAsync(imagePath)
164164+ }
165165+ } catch (err) {
166166+ logger.error(err instanceof Error ? err : String(err), {
167167+ message: 'Failed to save image to media library',
168168+ })
169169+ } finally {
170170+ safeDeleteAsync(imagePath)
171171+ }
144172}
145173146174export function getImageDim(path: string): Promise<Dimensions> {
+1-1
src/view/com/lightbox/Lightbox.tsx
···4141 }
4242 try {
4343 await saveImageToMediaLibrary({uri})
4444- Toast.show(_(msg`Saved to your camera roll`))
4444+ Toast.show(_(msg`Image saved`))
4545 } catch (e: any) {
4646 Toast.show(_(msg`Failed to save image: ${String(e)}`), 'xmark')
4747 }