Skip to content

A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search

fix(mobile): replace deprecated ImagePicker.MediaTypeOptions with media type literal (#2528)

Evan Simkowitz1df8acb34c8e
diff --git a/apps/mobile/app/dashboard/(tabs)/(home)/index.tsx b/apps/mobile/app/dashboard/(tabs)/(home)/index.tsx
index f8c0dca3..11f7bd8f 100644
--- a/apps/mobile/app/dashboard/(tabs)/(home)/index.tsx
+++ b/apps/mobile/app/dashboard/(tabs)/(home)/index.tsx
@@ -44,19 +44,34 @@ function HeaderRight({
if (nativeEvent.event === "new") {
openNewBookmarkModal();
} else if (nativeEvent.event === "library") {
- const result = await ImagePicker.launchImageLibraryAsync({
- mediaTypes: ImagePicker.MediaTypeOptions.Images,
- quality: settings.imageQuality,
- allowsMultipleSelection: false,
- });
- if (!result.canceled) {
- uploadToastIdRef.current =
- sonnerToast.loading("Uploading image...");
- uploadAsset({
- type: result.assets[0].mimeType ?? "",
- name: result.assets[0].fileName ?? "",
- uri: result.assets[0].uri,
+ try {
+ const result = await ImagePicker.launchImageLibraryAsync({
+ mediaTypes: ["images"],
+ quality: settings.imageQuality,
+ allowsMultipleSelection: false,
});
+ if (!result.canceled) {
+ const asset = result.assets[0];
+ if (!asset) {
+ uploadToastIdRef.current = null;
+ return;
+ }
+ uploadToastIdRef.current =
+ sonnerToast.loading("Uploading image...");
+ uploadAsset({
+ type: asset.mimeType ?? "",
+ name: asset.fileName ?? "",
+ uri: asset.uri,
+ });
+ }
+ } catch {
+ sonnerToast.error("Failed to open photo library", {
+ id:
+ uploadToastIdRef.current !== null
+ ? uploadToastIdRef.current
+ : undefined,
+ });
+ uploadToastIdRef.current = null;
}
}
}}