diff options
author | Ansh <anshnanda10@gmail.com> | 2023-07-03 11:17:12 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-03 13:17:12 -0500 |
commit | edff1992b18a62f4ada09ba4f20cd2c29cd4e634 (patch) | |
tree | 8ff31720b2ac06b1726a5f486aa3ac7a6673434a /src/lib/media/manip.ts | |
parent | 7cf0db7d14736e7bb109804fe94291525c8e96a7 (diff) | |
download | voidsky-edff1992b18a62f4ada09ba4f20cd2c29cd4e634.tar.zst |
Add permission checks before saving image (#945)
* catch permission errors when saving image to album * Save photos to media library alone (not an album) --------- Co-authored-by: Paul Frazee <pfrazee@gmail.com>
Diffstat (limited to 'src/lib/media/manip.ts')
-rw-r--r-- | src/lib/media/manip.ts | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/src/lib/media/manip.ts b/src/lib/media/manip.ts index 2f6c25e83..a681627e6 100644 --- a/src/lib/media/manip.ts +++ b/src/lib/media/manip.ts @@ -108,13 +108,7 @@ export async function shareImageModal({uri}: {uri: string}) { RNFS.unlink(imagePath) } -export async function saveImageToAlbum({ - uri, - album, -}: { - uri: string - album: string -}) { +export async function saveImageToMediaLibrary({uri}: {uri: string}) { // download the file to cache // NOTE // assuming PNG @@ -126,14 +120,8 @@ export async function saveImageToAlbum({ let imagePath = downloadResponse.path() imagePath = normalizePath(await moveToPermanentPath(imagePath, '.png'), true) - // save to the album (creating as needed) - const assetRef = await MediaLibrary.createAssetAsync(imagePath) - const albumRef = await MediaLibrary.getAlbumAsync(album) - if (albumRef) { - await MediaLibrary.addAssetsToAlbumAsync(assetRef, albumRef) - } else { - await MediaLibrary.createAlbumAsync(album, assetRef) - } + // save + await MediaLibrary.createAssetAsync(imagePath) } export function getImageDim(path: string): Promise<Dimensions> { |