From fd4a99678cd222941cc66de5d7fcd5f7615f375d Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Sun, 24 Nov 2024 16:03:45 +0000 Subject: deps(mobile): Upgrade to Expo 52 (#692) * fix(mobile): Sharing bookmark modal * WIP: Upgrade to 52 * post ugprade fixes * more fixes * fix padding in tabbar --- apps/mobile/app/_layout.tsx | 17 +++--- apps/mobile/app/dashboard/(tabs)/_layout.tsx | 4 +- .../mobile/app/dashboard/bookmarks/[slug]/info.tsx | 65 +++++++++++++--------- .../app/dashboard/bookmarks/[slug]/manage_tags.tsx | 38 ++++++------- apps/mobile/app/sharing.tsx | 35 ++++-------- apps/mobile/components/navigation/tabs.tsx | 5 +- apps/mobile/components/ui/Toast.tsx | 2 +- apps/mobile/package.json | 55 +++++++++--------- 8 files changed, 108 insertions(+), 113 deletions(-) (limited to 'apps/mobile') diff --git a/apps/mobile/app/_layout.tsx b/apps/mobile/app/_layout.tsx index 62c29c27..3a8f99a1 100644 --- a/apps/mobile/app/_layout.tsx +++ b/apps/mobile/app/_layout.tsx @@ -33,9 +33,9 @@ export default function RootLayout() { }, [settings.theme]); return ( - - - + + + - + - - - + + + ); } diff --git a/apps/mobile/app/dashboard/(tabs)/_layout.tsx b/apps/mobile/app/dashboard/(tabs)/_layout.tsx index cf1eb01f..46bf0f77 100644 --- a/apps/mobile/app/dashboard/(tabs)/_layout.tsx +++ b/apps/mobile/app/dashboard/(tabs)/_layout.tsx @@ -6,8 +6,8 @@ import { ClipboardList, Home, Settings } from "lucide-react-native"; export default function TabLayout() { return ( Tags - {isBookmarkStillTagging(bookmark) ? ( - <> - - - - ) : bookmark.tags.length > 0 ? ( - + + {isBookmarkStillTagging(bookmark) ? ( + + + + + ) : bookmark.tags.length > 0 ? ( {bookmark.tags.map((t) => ( ))} - - - router.push(`/dashboard/bookmarks/${bookmark.id}/manage_tags`) - } - className="flex w-full flex-row justify-between gap-3 rounded-lg bg-white px-4 py-2 dark:bg-accent" - > - Manage Tags - - - - ) : ( - No tags - )} + ) : ( + No tags + )} + + router.push(`/dashboard/bookmarks/${bookmark.id}/manage_tags`) + } + className="flex w-full flex-row justify-between gap-3 rounded-lg bg-white px-4 py-2 dark:bg-accent" + > + Manage Tags + + + ); } @@ -133,11 +134,12 @@ const ViewBookmarkPage = () => { if (typeof slug !== "string") { throw new Error("Unexpected param type"); } + const { data: bookmark, isPending, refetch, - } = api.bookmarks.getBookmark.useQuery({ bookmarkId: slug }); + } = useAutoRefreshingBookmarkQuery({ bookmarkId: slug }); if (isPending) { return ; @@ -167,6 +169,19 @@ const ViewBookmarkPage = () => { options={{ headerShown: true, headerTitle: title ?? "Untitled", + headerRight: () => ( + { + if (router.canGoBack()) { + router.back(); + } else { + router.replace("dashboard"); + } + }} + > + Done + + ), }} /> diff --git a/apps/mobile/app/dashboard/bookmarks/[slug]/manage_tags.tsx b/apps/mobile/app/dashboard/bookmarks/[slug]/manage_tags.tsx index 8429e4ba..3f24237b 100644 --- a/apps/mobile/app/dashboard/bookmarks/[slug]/manage_tags.tsx +++ b/apps/mobile/app/dashboard/bookmarks/[slug]/manage_tags.tsx @@ -8,7 +8,10 @@ import { Input } from "@/components/ui/Input"; import { useToast } from "@/components/ui/Toast"; import { Check, Plus } from "lucide-react-native"; -import { useUpdateBookmarkTags } from "@hoarder/shared-react/hooks/bookmarks"; +import { + useAutoRefreshingBookmarkQuery, + useUpdateBookmarkTags, +} from "@hoarder/shared-react/hooks/bookmarks"; import { api } from "@hoarder/shared-react/trpc"; const NEW_TAG_ID = "new-tag"; @@ -47,28 +50,21 @@ const ListPickerPage = () => { ), }, ); - const { data: existingTags } = api.bookmarks.getBookmark.useQuery( - { - bookmarkId, - }, - { - select: React.useCallback( - (data: { tags: { id: string; name: string }[] }) => - data.tags.map((t) => ({ - id: t.id, - name: t.name, - lowered: t.name.toLowerCase(), - })), - [], - ), - }, - ); + const { data: existingTags } = useAutoRefreshingBookmarkQuery({ + bookmarkId, + }); - const [optimisticTags, setOptimisticTags] = React.useState( - existingTags ?? [], - ); + const [optimisticTags, setOptimisticTags] = React.useState< + { id: string; name: string; lowered: string }[] + >([]); React.useEffect(() => { - setOptimisticTags(existingTags ?? []); + setOptimisticTags( + existingTags?.tags.map((t) => ({ + id: t.id, + name: t.name, + lowered: t.name.toLowerCase(), + })) ?? [], + ); }, [existingTags]); const { mutate: updateTags } = useUpdateBookmarkTags({ diff --git a/apps/mobile/app/sharing.tsx b/apps/mobile/app/sharing.tsx index 3551aea9..e2e1823b 100644 --- a/apps/mobile/app/sharing.tsx +++ b/apps/mobile/app/sharing.tsx @@ -52,7 +52,7 @@ function SaveBookmark({ setMode }: { setMode: (mode: Mode) => void }) { } } else if (!isPending && shareIntent?.files) { uploadAsset({ - type: shareIntent.files[0].type, + type: shareIntent.files[0].mimeType, name: shareIntent.files[0].fileName ?? "", uri: shareIntent.files[0].path, }); @@ -96,30 +96,15 @@ export default function Sharing() { {mode.type === "alreadyExists" ? "Already Hoarded!" : "Hoarded!"} - -