Merge remote-tracking branch 'origin' into hailey/79fab

This commit is contained in:
Hailey
2025-05-08 17:11:52 -07:00
6 changed files with 37 additions and 8 deletions
+1 -1
View File
@@ -73,7 +73,7 @@ function ShareDialogInner({
try {
await saveImageToMediaLibrary({uri: imageUrl})
Toast.show(_(msg`Image saved to your camera roll!`))
Toast.show(_(msg`Image saved`))
control.close()
} catch (e: unknown) {
Toast.show(_(msg`An error occurred while saving the image!`), 'xmark')
+31 -2
View File
@@ -95,6 +95,8 @@ export async function shareImageModal({uri}: {uri: string}) {
})
}
const ALBUM_NAME = 'Bluesky'
export async function saveImageToMediaLibrary({uri}: {uri: string}) {
// download the file to cache
// NOTE
@@ -103,8 +105,35 @@ export async function saveImageToMediaLibrary({uri}: {uri: string}) {
// -prf
const imageUri = await downloadImage(uri, createPath('png'), 5e3)
const imagePath = await moveToPermanentPath(imageUri, '.png')
safeDeleteAsync(imageUri)
MediaLibrary.createAssetAsync(imagePath)
// save
try {
if (isAndroid) {
// android triggers an annoying permission prompt if you try and move an image
// between albums. therefore, we need to either create the album with the image
// as the starting image, or put it directly into the album
const album = await MediaLibrary.getAlbumAsync(ALBUM_NAME)
if (album) {
// if album exists, put the image straight in there
await MediaLibrary.createAssetAsync(imagePath, album)
} else {
// otherwise, create album with asset (albums must always have at least one asset)
await MediaLibrary.createAlbumAsync(
ALBUM_NAME,
undefined,
undefined,
imagePath,
)
}
} else {
await MediaLibrary.createAssetAsync(imagePath)
}
} catch (err) {
logger.error(err instanceof Error ? err : String(err), {
message: 'Failed to save image to media library',
})
} finally {
safeDeleteAsync(imagePath)
}
}
export function getImageDim(path: string): Promise<Dimensions> {
+1 -1
View File
@@ -44,7 +44,7 @@ export async function shareImageModal(_opts: {uri: string}) {
throw new Error('TODO')
}
export async function saveImageToAlbum(_opts: {uri: string; album: string}) {
export async function saveImageToMediaLibrary(_opts: {uri: string}) {
// TODO
throw new Error('TODO')
}
+2 -2
View File
@@ -5,14 +5,14 @@
import {init} from '@sentry/react-native'
import {version} from '#/../package.json'
import pkgJson from '#/../package.json'
/**
* Examples:
* - `dev`
* - `1.99.0`
*/
const release = process.env.SENTRY_RELEASE || version
const release = process.env.SENTRY_RELEASE || pkgJson.version
/**
* The latest deployed commit hash
+1 -1
View File
@@ -94,7 +94,7 @@ export function ComposerReplyTo({replyTo}: {replyTo: ComposerOptsPostRef}) {
<View style={[a.flex_1, a.pl_md, a.pr_sm, a.gap_2xs]}>
<View style={[a.flex_row, a.align_center, a.pr_xs]}>
<Text
style={[a.font_bold, a.text_md, a.flex_shrink]}
style={[a.font_bold, a.text_md, a.leading_snug, a.flex_shrink]}
numberOfLines={1}
emoji>
{sanitizeDisplayName(
+1 -1
View File
@@ -41,7 +41,7 @@ export function Lightbox() {
}
try {
await saveImageToMediaLibrary({uri})
Toast.show(_(msg`Saved to your camera roll`))
Toast.show(_(msg`Image saved`))
} catch (e: any) {
Toast.show(_(msg`Failed to save image: ${String(e)}`), 'xmark')
}