A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search
ui(mobile): Replace bottom sheet with native screens (#690)
Mohamed Bassem5522e20104da
diff --git a/apps/mobile/app/_layout.tsx b/apps/mobile/app/_layout.tsxindex 5eadad80..62c29c27 100644--- a/apps/mobile/app/_layout.tsx+++ b/apps/mobile/app/_layout.tsx@@ -12,7 +12,6 @@ import { StyledStack } from "@/components/navigation/stack";import { Providers } from "@/lib/providers";import useAppSettings from "@/lib/settings";import { cn } from "@/lib/utils";-import { BottomSheetModalProvider } from "@gorhom/bottom-sheet";import { useColorScheme } from "nativewind";export default function RootLayout() {@@ -37,44 +36,45 @@ export default function RootLayout() {<ShareIntentProvider><Providers><GestureHandlerRootView style={{ flex: 1 }}>- <BottomSheetModalProvider>- <View- className={cn(- "w-full flex-1 bg-gray-100 text-foreground dark:bg-background",- colorScheme == "dark" ? "dark" : "light",- )}+ <View+ className={cn(+ "w-full flex-1 bg-gray-100 text-foreground dark:bg-background",+ colorScheme == "dark" ? "dark" : "light",+ )}+ >+ <StyledStack+ contentClassName="bg-gray-100 dark:bg-background"+ screenOptions={{+ headerShown: false,+ headerTransparent: true,+ }}>- <StyledStack- contentClassName="bg-gray-100 dark:bg-background"- screenOptions={{- headerShown: false,- headerTransparent: true,+ <Stack.Screen name="index" />+ <Stack.Screen+ name="signin"+ options={{+ headerShown: true,+ headerBackVisible: true,+ headerBackTitle: "Back",+ title: "",}}- >- <Stack.Screen name="index" />- <Stack.Screen- name="signin"- options={{- headerShown: true,- headerBackVisible: true,- headerBackTitle: "Back",- title: "",- }}- />- <Stack.Screen name="server-address" />- <Stack.Screen name="sharing" />- <Stack.Screen- name="test-connection"- options={{- title: "Test Connection",- headerShown: true,- presentation: "modal",- }}- />- </StyledStack>- <StatusBar style="auto" />- </View>- </BottomSheetModalProvider>+ />+ <Stack.Screen name="server-address" />+ <Stack.Screen+ name="sharing"+ options={{ presentation: "modal" }}+ />+ <Stack.Screen+ name="test-connection"+ options={{+ title: "Test Connection",+ headerShown: true,+ presentation: "modal",+ }}+ />+ </StyledStack>+ <StatusBar style="auto" />+ </View></GestureHandlerRootView></Providers></ShareIntentProvider>diff --git a/apps/mobile/app/dashboard/(tabs)/index.tsx b/apps/mobile/app/dashboard/(tabs)/index.tsxindex b9ab7d11..f70474a9 100644--- a/apps/mobile/app/dashboard/(tabs)/index.tsx+++ b/apps/mobile/app/dashboard/(tabs)/index.tsx@@ -1,9 +1,7 @@-import { useRef } from "react";import { Platform, Pressable, Text, View } from "react-native";import * as Haptics from "expo-haptics";import * as ImagePicker from "expo-image-picker";import { router } from "expo-router";-import NoteEditorModal from "@/components/bookmarks/NewBookmarkModal";import UpdatingBookmarkList from "@/components/bookmarks/UpdatingBookmarkList";import { TailwindResolver } from "@/components/TailwindResolver";import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView";@@ -11,7 +9,6 @@ import PageTitle from "@/components/ui/PageTitle";import { useToast } from "@/components/ui/Toast";import useAppSettings from "@/lib/settings";import { useUploadAsset } from "@/lib/upload";-import { BottomSheetModal } from "@gorhom/bottom-sheet";import { MenuView } from "@react-native-menu/menu";import { Plus, Search } from "lucide-react-native";@@ -77,11 +74,8 @@ function HeaderRight({}export default function Home() {- const newBookmarkModal = useRef<BottomSheetModal>(null);-return (<CustomSafeAreaView>- <NoteEditorModal ref={newBookmarkModal} snapPoints={["90%", "60%"]} /><UpdatingBookmarkListquery={{ archived: false }}header={@@ -89,7 +83,9 @@ export default function Home() {<View className="flex flex-row justify-between"><PageTitle title="Home" className="pb-2" /><HeaderRight- openNewBookmarkModal={() => newBookmarkModal.current?.present()}+ openNewBookmarkModal={() =>+ router.push("/dashboard/bookmarks/new")+ }/></View><Pressablediff --git a/apps/mobile/app/dashboard/(tabs)/lists.tsx b/apps/mobile/app/dashboard/(tabs)/lists.tsxindex fa97f67a..9cc49cd4 100644--- a/apps/mobile/app/dashboard/(tabs)/lists.tsx+++ b/apps/mobile/app/dashboard/(tabs)/lists.tsx@@ -1,15 +1,13 @@-import { useEffect, useRef, useState } from "react";+import { useEffect, useState } from "react";import { FlatList, Pressable, Text, View } from "react-native";import * as Haptics from "expo-haptics";-import { Link } from "expo-router";+import { Link, router } from "expo-router";import FullPageError from "@/components/FullPageError";-import NewListModal from "@/components/lists/NewListModal";import { TailwindResolver } from "@/components/TailwindResolver";import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView";import FullPageSpinner from "@/components/ui/FullPageSpinner";import PageTitle from "@/components/ui/PageTitle";import { api } from "@/lib/trpc";-import { BottomSheetModal } from "@gorhom/bottom-sheet";import { ChevronRight, Plus } from "lucide-react-native";import { useBookmarkLists } from "@hoarder/shared-react/hooks/lists";@@ -72,7 +70,6 @@ export default function Lists() {{},);const apiUtils = api.useUtils();- const newListModal = useRef<BottomSheetModal>(null);useEffect(() => {setRefreshing(isPending);@@ -117,14 +114,13 @@ export default function Lists() {return (<CustomSafeAreaView>- <NewListModal ref={newListModal} snapPoints={["90%"]} /><FlatListclassName="h-full"ListHeaderComponent={<View className="flex flex-row justify-between"><PageTitle title="Lists" /><HeaderRight- openNewListModal={() => newListModal.current?.present()}+ openNewListModal={() => router.push("/dashboard/lists/new")}/></View>}diff --git a/apps/mobile/app/dashboard/_layout.tsx b/apps/mobile/app/dashboard/_layout.tsxindex 609f06f5..bc743c7a 100644--- a/apps/mobile/app/dashboard/_layout.tsx+++ b/apps/mobile/app/dashboard/_layout.tsx@@ -49,6 +49,49 @@ export default function Dashboard() {headerTransparent: true,}}/>+ <Stack.Screen+ name="bookmarks/[slug]/index"+ options={{+ headerTitle: "",+ headerBackTitle: "Back",+ headerTransparent: true,+ }}+ />+ <Stack.Screen+ name="bookmarks/new"+ options={{+ headerTitle: "New Bookmark",+ headerBackTitle: "Back",+ headerTransparent: true,+ presentation: "modal",+ }}+ />+ <Stack.Screen+ name="bookmarks/[slug]/manage_lists"+ options={{+ headerTitle: "Manage Lists",+ headerBackTitle: "Back",+ headerTransparent: true,+ presentation: "modal",+ }}+ />+ <Stack.Screen+ name="bookmarks/[slug]/info"+ options={{+ headerBackTitle: "Back",+ headerTransparent: true,+ presentation: "modal",+ }}+ />+ <Stack.Screen+ name="lists/new"+ options={{+ headerTitle: "New List",+ headerBackTitle: "Back",+ headerTransparent: true,+ presentation: "modal",+ }}+ /><Stack.Screenname="archive"options={{@@ -64,6 +107,8 @@ export default function Dashboard() {headerBackTitle: "",headerTransparent: true,headerShown: false,+ animation: "fade_from_bottom",+ animationDuration: 100,}}/><Stack.Screendiff --git a/apps/mobile/app/dashboard/add-link.tsx b/apps/mobile/app/dashboard/add-link.tsxdeleted file mode 100644index d9773fb4..00000000--- a/apps/mobile/app/dashboard/add-link.tsx+++ /dev/null@@ -1,64 +0,0 @@-import { useState } from "react";-import { Text, View } from "react-native";-import { useRouter } from "expo-router";-import { Button } from "@/components/ui/Button";-import { Input } from "@/components/ui/Input";-import { useToast } from "@/components/ui/Toast";-import { api } from "@/lib/trpc";--import { BookmarkTypes } from "@hoarder/shared/types/bookmarks";--export default function AddNote() {- const [text, setText] = useState("");- const [error, setError] = useState<string | undefined>();- const { toast } = useToast();- const router = useRouter();- const invalidateAllBookmarks =- api.useUtils().bookmarks.getBookmarks.invalidate;-- const { mutate } = api.bookmarks.createBookmark.useMutation({- onSuccess: (resp) => {- if (resp.alreadyExists) {- toast({- message: "Bookmark already exists",- });- }- invalidateAllBookmarks();- if (router.canGoBack()) {- router.replace("../");- } else {- router.replace("dashboard");- }- },- onError: (e) => {- let message;- if (e.data?.zodError) {- const zodError = e.data.zodError;- message = JSON.stringify(zodError);- } else {- message = `Something went wrong: ${e.message}`;- }- setError(message);- },- });-- return (- <View className="flex gap-2 p-4">- {error && (- <Text className="w-full text-center text-red-500">{error}</Text>- )}- <Input- value={text}- onChangeText={setText}- placeholder="Link"- autoCapitalize="none"- inputMode="url"- autoFocus- />- <Button- onPress={() => mutate({ type: BookmarkTypes.LINK, url: text })}- label="Add Link"- />- </View>- );-}diff --git a/apps/mobile/app/dashboard/bookmarks/[slug].tsx b/apps/mobile/app/dashboard/bookmarks/[slug]/index.tsxsimilarity index 89%rename from apps/mobile/app/dashboard/bookmarks/[slug].tsxrename to apps/mobile/app/dashboard/bookmarks/[slug]/index.tsxindex 9459488a..87330a88 100644--- a/apps/mobile/app/dashboard/bookmarks/[slug].tsx+++ b/apps/mobile/app/dashboard/bookmarks/[slug]/index.tsx@@ -1,4 +1,4 @@-import React, { useRef, useState } from "react";+import React, { useState } from "react";import {Alert,Keyboard,@@ -12,8 +12,6 @@ import WebView from "react-native-webview";import { Stack, useLocalSearchParams, useRouter } from "expo-router";import BookmarkAssetImage from "@/components/bookmarks/BookmarkAssetImage";import BookmarkTextMarkdown from "@/components/bookmarks/BookmarkTextMarkdown";-import ListPickerModal from "@/components/bookmarks/ListPickerModal";-import ViewBookmarkModal from "@/components/bookmarks/ViewBookmarkModal";import FullPageError from "@/components/FullPageError";import { TailwindResolver } from "@/components/TailwindResolver";import { Button } from "@/components/ui/Button";@@ -23,13 +21,7 @@ import { Input } from "@/components/ui/Input";import { useToast } from "@/components/ui/Toast";import { useAssetUrl } from "@/lib/hooks";import { api } from "@/lib/trpc";-import { BottomSheetModal } from "@gorhom/bottom-sheet";-import {- ArrowUpFromLine,- ClipboardList,- Globe,- Trash2,-} from "lucide-react-native";+import { ClipboardList, Globe, Info, Trash2 } from "lucide-react-native";import {useDeleteBookmark,@@ -40,8 +32,6 @@ import { BookmarkTypes, ZBookmark } from "@hoarder/shared/types/bookmarks";function BottomActions({ bookmark }: { bookmark: ZBookmark }) {const { toast } = useToast();const router = useRouter();- const viewBookmarkModal = useRef<BottomSheetModal>(null);- const manageListsSheetRef = useRef<BottomSheetModal>(null);const { mutate: deleteBookmark, isPending: isDeletionPending } =useDeleteBookmark({onSuccess: () => {@@ -84,7 +74,8 @@ function BottomActions({ bookmark }: { bookmark: ZBookmark }) {/>),shouldRender: true,- onClick: () => manageListsSheetRef.current?.present(),+ onClick: () =>+ router.push(`/dashboard/bookmarks/${bookmark.id}/manage_lists`),disabled: false,},{@@ -92,13 +83,11 @@ function BottomActions({ bookmark }: { bookmark: ZBookmark }) {icon: (<TailwindResolverclassName="text-foreground"- comp={(styles) => (- <ArrowUpFromLine color={styles?.color?.toString()} />- )}+ comp={(styles) => <Info color={styles?.color?.toString()} />}/>),shouldRender: true,- onClick: () => viewBookmarkModal.current?.present(),+ onClick: () => router.push(`/dashboard/bookmarks/${bookmark.id}/info`),disabled: false,},{@@ -130,16 +119,6 @@ function BottomActions({ bookmark }: { bookmark: ZBookmark }) {];return (<View>- <ViewBookmarkModal- bookmark={bookmark}- ref={viewBookmarkModal}- snapPoints={["95%"]}- />- <ListPickerModal- ref={manageListsSheetRef}- snapPoints={["50%", "90%"]}- bookmarkId={bookmark.id}- /><View className="flex flex-row items-center justify-between px-10 pb-2 pt-4">{actions.map((a) =>diff --git a/apps/mobile/app/dashboard/bookmarks/[slug]/info.tsx b/apps/mobile/app/dashboard/bookmarks/[slug]/info.tsxnew file mode 100644index 00000000..5d15ab6b--- /dev/null+++ b/apps/mobile/app/dashboard/bookmarks/[slug]/info.tsx@@ -0,0 +1,115 @@+import React from "react";+import { Text, View } from "react-native";+import { Stack, useLocalSearchParams } from "expo-router";+import TagPill from "@/components/bookmarks/TagPill";+import FullPageError from "@/components/FullPageError";+import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView";+import FullPageSpinner from "@/components/ui/FullPageSpinner";+import { Input } from "@/components/ui/Input";+import { Skeleton } from "@/components/ui/Skeleton";+import { api } from "@/lib/trpc";++import { useUpdateBookmark } from "@hoarder/shared-react/hooks/bookmarks";+import { isBookmarkStillTagging } from "@hoarder/shared-react/utils/bookmarkUtils";+import { BookmarkTypes, ZBookmark } from "@hoarder/shared/types/bookmarks";++function TagList({ bookmark }: { bookmark: ZBookmark }) {+ return (+ <View className="flex flex-row items-center gap-4">+ <Text className="text-foreground">Tags</Text>+ {isBookmarkStillTagging(bookmark) ? (+ <>+ <Skeleton className="h-4 w-full" />+ <Skeleton className="h-4 w-full" />+ </>+ ) : bookmark.tags.length > 0 ? (+ <View className="flex flex-row flex-wrap gap-2">+ {bookmark.tags.map((t) => (+ <TagPill key={t.id} tag={t} />+ ))}+ </View>+ ) : (+ <Text className="text-foreground">No tags</Text>+ )}+ </View>+ );+}++function NotesEditor({ bookmark }: { bookmark: ZBookmark }) {+ const { mutate, isPending } = useUpdateBookmark();+ return (+ <View className="flex flex-row items-center gap-4">+ <Text className="text-foreground">Notes</Text>++ <Input+ className="flex-1"+ editable={!isPending}+ multiline={true}+ numberOfLines={3}+ loading={isPending}+ placeholder="Notes"+ textAlignVertical="top"+ onEndEditing={(ev) =>+ mutate({+ bookmarkId: bookmark.id,+ note: ev.nativeEvent.text,+ })+ }+ defaultValue={bookmark.note ?? ""}+ />+ </View>+ );+}++const ViewBookmarkPage = () => {+ const { slug } = useLocalSearchParams();+ if (typeof slug !== "string") {+ throw new Error("Unexpected param type");+ }+ const {+ data: bookmark,+ isPending,+ refetch,+ } = api.bookmarks.getBookmark.useQuery({ bookmarkId: slug });++ if (isPending) {+ return <FullPageSpinner />;+ }++ if (!bookmark) {+ return (+ <FullPageError error="Bookmark not found" onRetry={() => refetch()} />+ );+ }++ let title = null;+ switch (bookmark.content.type) {+ case BookmarkTypes.LINK:+ title = bookmark.title ?? bookmark.content.title;+ break;+ case BookmarkTypes.TEXT:+ title = bookmark.title;+ break;+ case BookmarkTypes.ASSET:+ title = bookmark.title ?? bookmark.content.fileName;+ break;+ }+ return (+ <CustomSafeAreaView>+ <Stack.Screen+ options={{+ headerShown: true,+ headerTitle: title ?? "Untitled",+ }}+ />+ <View className="w-full p-4">+ <View className="gap-4 px-4">+ <TagList bookmark={bookmark} />+ <NotesEditor bookmark={bookmark} />+ </View>+ </View>+ </CustomSafeAreaView>+ );+};++export default ViewBookmarkPage;diff --git a/apps/mobile/app/dashboard/bookmarks/[slug]/manage_lists.tsx b/apps/mobile/app/dashboard/bookmarks/[slug]/manage_lists.tsxnew file mode 100644index 00000000..b38261df--- /dev/null+++ b/apps/mobile/app/dashboard/bookmarks/[slug]/manage_lists.tsx@@ -0,0 +1,105 @@+import React from "react";+import { FlatList, Pressable, Text, View } from "react-native";+import Checkbox from "expo-checkbox";+import { useLocalSearchParams } from "expo-router";+import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView";+import { useToast } from "@/components/ui/Toast";++import {+ useAddBookmarkToList,+ useBookmarkLists,+ useRemoveBookmarkFromList,+} from "@hoarder/shared-react/hooks/lists";+import { api } from "@hoarder/shared-react/trpc";++const ListPickerPage = () => {+ const { slug: bookmarkId } = useLocalSearchParams();+ if (typeof bookmarkId !== "string") {+ throw new Error("Unexpected param type");+ }+ const { toast } = useToast();+ const onError = () => {+ toast({+ message: "Something went wrong",+ variant: "destructive",+ showProgress: false,+ });+ };+ const { data: existingLists } = api.lists.getListsOfBookmark.useQuery(+ {+ bookmarkId,+ },+ {+ select: (data) => new Set(data.lists.map((l) => l.id)),+ },+ );+ const { data } = useBookmarkLists();++ const { mutate: addToList } = useAddBookmarkToList({+ onSuccess: () => {+ toast({+ message: `The bookmark has been added to the list!`,+ showProgress: false,+ });+ },+ onError,+ });++ const { mutate: removeToList } = useRemoveBookmarkFromList({+ onSuccess: () => {+ toast({+ message: `The bookmark has been removed from the list!`,+ showProgress: false,+ });+ },+ onError,+ });++ const toggleList = (listId: string) => {+ if (!existingLists) {+ return;+ }+ if (existingLists.has(listId)) {+ removeToList({ bookmarkId, listId });+ } else {+ addToList({ bookmarkId, listId });+ }+ };++ const { allPaths } = data ?? {};+ return (+ <CustomSafeAreaView>+ <FlatList+ className="h-full"+ contentContainerStyle={{+ gap: 5,+ }}+ renderItem={(l) => (+ <View className="mx-2 flex flex-row items-center rounded-xl border border-input bg-white px-4 py-2 dark:bg-accent">+ <Pressable+ key={l.item[l.item.length - 1].id}+ onPress={() => toggleList(l.item[l.item.length - 1].id)}+ className="flex w-full flex-row justify-between"+ >+ <Text className="text-lg text-accent-foreground">+ {l.item.map((item) => `${item.icon} ${item.name}`).join(" / ")}+ </Text>+ <Checkbox+ value={+ existingLists &&+ existingLists.has(l.item[l.item.length - 1].id)+ }+ onValueChange={() => {+ toggleList(l.item[l.item.length - 1].id);+ }}+ />+ </Pressable>+ </View>+ )}+ data={allPaths}+ />+ </CustomSafeAreaView>+ );+};++export default ListPickerPage;diff --git a/apps/mobile/app/dashboard/bookmarks/new.tsx b/apps/mobile/app/dashboard/bookmarks/new.tsxnew file mode 100644index 00000000..06a16a40--- /dev/null+++ b/apps/mobile/app/dashboard/bookmarks/new.tsx@@ -0,0 +1,76 @@+import React, { useState } from "react";+import { Text, View } from "react-native";+import { router } from "expo-router";+import { Button } from "@/components/ui/Button";+import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView";+import { Input } from "@/components/ui/Input";+import { useToast } from "@/components/ui/Toast";++import { useCreateBookmark } from "@hoarder/shared-react/hooks/bookmarks";+import { BookmarkTypes } from "@hoarder/shared/types/bookmarks";++const NoteEditorPage = () => {+ const dismiss = () => {+ router.back();+ };++ const [text, setText] = useState("");+ const [error, setError] = useState<string | undefined>();+ const { toast } = useToast();++ const { mutate: createBookmark } = useCreateBookmark({+ onSuccess: (resp) => {+ if (resp.alreadyExists) {+ toast({+ message: "Bookmark already exists",+ });+ }+ setText("");+ dismiss();+ },+ onError: (e) => {+ let message;+ if (e.data?.zodError) {+ const zodError = e.data.zodError;+ message = JSON.stringify(zodError);+ } else {+ message = `Something went wrong: ${e.message}`;+ }+ setError(message);+ },+ });++ const onSubmit = () => {+ const data = text.trim();+ try {+ const url = new URL(data);+ if (url.protocol != "http:" && url.protocol != "https:") {+ throw new Error(`Unsupported URL protocol: ${url.protocol}`);+ }+ createBookmark({ type: BookmarkTypes.LINK, url: data });+ } catch (e: unknown) {+ createBookmark({ type: BookmarkTypes.TEXT, text: data });+ }+ };++ return (+ <CustomSafeAreaView>+ <View className="gap-2 px-4">+ {error && (+ <Text className="w-full text-center text-red-500">{error}</Text>+ )}+ <Input+ onChangeText={setText}+ multiline+ placeholder="What's on your mind?"+ autoFocus+ autoCapitalize={"none"}+ textAlignVertical="top"+ />+ <Button onPress={onSubmit} label="Save" />+ </View>+ </CustomSafeAreaView>+ );+};++export default NoteEditorPage;diff --git a/apps/mobile/app/dashboard/lists/new.tsx b/apps/mobile/app/dashboard/lists/new.tsxnew file mode 100644index 00000000..998638aa--- /dev/null+++ b/apps/mobile/app/dashboard/lists/new.tsx@@ -0,0 +1,56 @@+import React, { useState } from "react";+import { Text, View } from "react-native";+import { router } from "expo-router";+import { Button } from "@/components/ui/Button";+import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView";+import { Input } from "@/components/ui/Input";+import { useToast } from "@/components/ui/Toast";++import { useCreateBookmarkList } from "@hoarder/shared-react/hooks/lists";++const NewListPage = () => {+ const dismiss = () => {+ router.back();+ };+ const { toast } = useToast();+ const [text, setText] = useState("");++ const { mutate, isPending } = useCreateBookmarkList({+ onSuccess: () => {+ dismiss();+ },+ onError: () => {+ toast({+ message: "Something went wrong",+ variant: "destructive",+ });+ },+ });++ const onSubmit = () => {+ mutate({+ name: text,+ icon: "🚀",+ });+ };++ return (+ <CustomSafeAreaView>+ <View className="gap-2 px-4">+ <View className="flex flex-row items-center gap-1">+ <Text className="shrink p-2">🚀</Text>+ <Input+ className="flex-1"+ onChangeText={setText}+ placeholder="List Name"+ autoFocus+ autoCapitalize={"none"}+ />+ </View>+ <Button disabled={isPending} onPress={onSubmit} label="Save" />+ </View>+ </CustomSafeAreaView>+ );+};++export default NewListPage;diff --git a/apps/mobile/app/sharing.tsx b/apps/mobile/app/sharing.tsxindex ee7bd609..e41535b7 100644--- a/apps/mobile/app/sharing.tsx+++ b/apps/mobile/app/sharing.tsx@@ -1,13 +1,11 @@-import { useEffect, useRef, useState } from "react";-import { ActivityIndicator, Text, View } from "react-native";+import { useEffect, useState } from "react";+import { ActivityIndicator, Pressable, Text, View } from "react-native";import { useRouter } from "expo-router";import { useShareIntentContext } from "expo-share-intent";-import ListPickerModal from "@/components/bookmarks/ListPickerModal";import { Button } from "@/components/ui/Button";import useAppSettings from "@/lib/settings";import { api } from "@/lib/trpc";import { useUploadAsset } from "@/lib/upload";-import { BottomSheetModal } from "@gorhom/bottom-sheet";import { z } from "zod";import { BookmarkTypes, ZBookmark } from "@hoarder/shared/types/bookmarks";@@ -84,7 +82,6 @@ export default function Sharing() {const [mode, setMode] = useState<Mode>({ type: "idle" });let autoCloseTimeoutId: NodeJS.Timeout | null = null;- const addToListSheetRef = useRef<BottomSheetModal>(null);let comp;switch (mode.type) {@@ -96,24 +93,23 @@ export default function Sharing() {case "success": {comp = (<View className="items-center gap-4">- <ListPickerModal- ref={addToListSheetRef}- snapPoints={["90%"]}- bookmarkId={mode.bookmarkId}- onDismiss={() => router.replace("dashboard")}- /><Text className="text-4xl text-foreground">{mode.type === "alreadyExists" ? "Already Hoarded!" : "Hoarded!"}</Text><Buttonlabel="Add to List"onPress={() => {- addToListSheetRef.current?.present();+ router.push(+ `/dashboard/bookmarks/${mode.bookmarkId}/manage_lists`,+ );if (autoCloseTimeoutId) {clearTimeout(autoCloseTimeoutId);}}}/>+ <Pressable onPress={() => router.replace("dashboard")}>+ <Text className="text-muted-foreground">Dismiss</Text>+ </Pressable></View>);break;diff --git a/apps/mobile/components/bookmarks/BookmarkCard.tsx b/apps/mobile/components/bookmarks/BookmarkCard.tsxindex 5d84ee6f..df5aa666 100644--- a/apps/mobile/components/bookmarks/BookmarkCard.tsx+++ b/apps/mobile/components/bookmarks/BookmarkCard.tsx@@ -1,4 +1,3 @@-import { useRef } from "react";import {ActivityIndicator,Image,@@ -9,10 +8,9 @@ import {View,} from "react-native";import * as Haptics from "expo-haptics";-import { useRouter } from "expo-router";+import { router, useRouter } from "expo-router";import useAppSettings from "@/lib/settings";import { api } from "@/lib/trpc";-import { BottomSheetModal } from "@gorhom/bottom-sheet";import { MenuView } from "@react-native-menu/menu";import { Ellipsis, Star } from "lucide-react-native";@@ -33,7 +31,6 @@ import { Skeleton } from "../ui/Skeleton";import { useToast } from "../ui/Toast";import BookmarkAssetImage from "./BookmarkAssetImage";import BookmarkTextMarkdown from "./BookmarkTextMarkdown";-import ListPickerModal from "./ListPickerModal";import TagPill from "./TagPill";function ActionBar({ bookmark }: { bookmark: ZBookmark }) {@@ -73,8 +70,6 @@ function ActionBar({ bookmark }: { bookmark: ZBookmark }) {onError,});- const manageListsSheetRef = useRef<BottomSheetModal>(null);-return (<View className="flex flex-row gap-4">{(isArchivePending || isDeletionPending) && <ActivityIndicator />}@@ -94,12 +89,6 @@ function ActionBar({ bookmark }: { bookmark: ZBookmark }) {)}</Pressable>- <ListPickerModal- ref={manageListsSheetRef}- snapPoints={["50%", "90%"]}- bookmarkId={bookmark.id}- />-<MenuViewonPressAction={({ nativeEvent }) => {Haptics.selectionAsync();@@ -113,7 +102,7 @@ function ActionBar({ bookmark }: { bookmark: ZBookmark }) {archived: !bookmark.archived,});} else if (nativeEvent.event === "manage_list") {- manageListsSheetRef?.current?.present();+ router.push(`/dashboard/bookmarks/${bookmark.id}/manage_lists`);}}}actions={[diff --git a/apps/mobile/components/bookmarks/ListPickerModal.tsx b/apps/mobile/components/bookmarks/ListPickerModal.tsxdeleted file mode 100644index 6079e53d..00000000--- a/apps/mobile/components/bookmarks/ListPickerModal.tsx+++ /dev/null@@ -1,117 +0,0 @@-import React from "react";-import { Pressable, Text, View } from "react-native";-import Checkbox from "expo-checkbox";-import {- BottomSheetFlatList,- BottomSheetModal,- BottomSheetModalProps,-} from "@gorhom/bottom-sheet";--import {- useAddBookmarkToList,- useBookmarkLists,- useRemoveBookmarkFromList,-} from "@hoarder/shared-react/hooks/lists";-import { api } from "@hoarder/shared-react/trpc";--import PageTitle from "../ui/PageTitle";-import { useToast } from "../ui/Toast";--const ListPickerModal = React.forwardRef<- BottomSheetModal,- Omit<BottomSheetModalProps, "children"> & {- bookmarkId: string;- }->(({ bookmarkId, ...props }, ref) => {- const { toast } = useToast();- const onError = () => {- toast({- message: "Something went wrong",- variant: "destructive",- showProgress: false,- });- };- const { data: existingLists } = api.lists.getListsOfBookmark.useQuery(- {- bookmarkId,- },- {- select: (data) => new Set(data.lists.map((l) => l.id)),- },- );- const { data } = useBookmarkLists();-- const { mutate: addToList } = useAddBookmarkToList({- onSuccess: () => {- toast({- message: `The bookmark has been added to the list!`,- showProgress: false,- });- },- onError,- });-- const { mutate: removeToList } = useRemoveBookmarkFromList({- onSuccess: () => {- toast({- message: `The bookmark has been removed from the list!`,- showProgress: false,- });- },- onError,- });-- const toggleList = (listId: string) => {- if (!existingLists) {- return;- }- if (existingLists.has(listId)) {- removeToList({ bookmarkId, listId });- } else {- addToList({ bookmarkId, listId });- }- };-- const { allPaths } = data ?? {};- return (- <View>- <BottomSheetModal ref={ref} {...props}>- <BottomSheetFlatList- ListHeaderComponent={<PageTitle title="Manage Lists" />}- className="h-full"- contentContainerStyle={{- gap: 5,- }}- renderItem={(l) => (- <View className="mx-2 flex flex-row items-center rounded-xl border border-input bg-white px-4 py-2 dark:bg-accent">- <Pressable- key={l.item[l.item.length - 1].id}- onPress={() => toggleList(l.item[l.item.length - 1].id)}- className="flex w-full flex-row justify-between"- >- <Text className="text-lg text-accent-foreground">- {l.item- .map((item) => `${item.icon} ${item.name}`)- .join(" / ")}- </Text>- <Checkbox- value={- existingLists &&- existingLists.has(l.item[l.item.length - 1].id)- }- onValueChange={() => {- toggleList(l.item[l.item.length - 1].id);- }}- />- </Pressable>- </View>- )}- data={allPaths}- />- </BottomSheetModal>- </View>- );-});-ListPickerModal.displayName = "ListPickerModal";--export default ListPickerModal;diff --git a/apps/mobile/components/bookmarks/NewBookmarkModal.tsx b/apps/mobile/components/bookmarks/NewBookmarkModal.tsxdeleted file mode 100644index 218c54b8..00000000--- a/apps/mobile/components/bookmarks/NewBookmarkModal.tsx+++ /dev/null@@ -1,98 +0,0 @@-import React, { useState } from "react";-import { Text, View } from "react-native";-import {- BottomSheetBackdrop,- BottomSheetModal,- BottomSheetModalProps,- BottomSheetView,- useBottomSheetModal,-} from "@gorhom/bottom-sheet";--import { useCreateBookmark } from "@hoarder/shared-react/hooks/bookmarks";-import { BookmarkTypes } from "@hoarder/shared/types/bookmarks";--import { Button } from "../ui/Button";-import { Input } from "../ui/Input";-import PageTitle from "../ui/PageTitle";-import { useToast } from "../ui/Toast";--const NoteEditorModal = React.forwardRef<- BottomSheetModal,- Omit<BottomSheetModalProps, "children" | "backdropComponent" | "onDismiss">->(({ ...props }, ref) => {- const { dismiss } = useBottomSheetModal();-- const [text, setText] = useState("");- const [error, setError] = useState<string | undefined>();- const { toast } = useToast();-- const { mutate: createBookmark } = useCreateBookmark({- onSuccess: (resp) => {- if (resp.alreadyExists) {- toast({- message: "Bookmark already exists",- });- }- setText("");- dismiss();- },- onError: (e) => {- let message;- if (e.data?.zodError) {- const zodError = e.data.zodError;- message = JSON.stringify(zodError);- } else {- message = `Something went wrong: ${e.message}`;- }- setError(message);- },- });-- const onSubmit = () => {- const data = text.trim();- try {- const url = new URL(data);- if (url.protocol != "http:" && url.protocol != "https:") {- throw new Error(`Unsupported URL protocol: ${url.protocol}`);- }- createBookmark({ type: BookmarkTypes.LINK, url: data });- } catch (e: unknown) {- createBookmark({ type: BookmarkTypes.TEXT, text: data });- }- };-- return (- <View>- <BottomSheetModal- ref={ref}- backdropComponent={(props) => (- <BottomSheetBackdrop- appearsOnIndex={0}- disappearsOnIndex={-1}- {...props}- />- )}- {...props}- >- <PageTitle title="New Bookmark" />- <BottomSheetView className="gap-2 p-4">- {error && (- <Text className="w-full text-center text-red-500">{error}</Text>- )}- <Input- onChangeText={setText}- multiline- placeholder="What's on your mind?"- autoFocus- autoCapitalize={"none"}- textAlignVertical="top"- />- <Button onPress={onSubmit} label="Save" />- </BottomSheetView>- </BottomSheetModal>- </View>- );-});-NoteEditorModal.displayName = "NewBookmarkModal";--export default NoteEditorModal;diff --git a/apps/mobile/components/bookmarks/ViewBookmarkModal.tsx b/apps/mobile/components/bookmarks/ViewBookmarkModal.tsxdeleted file mode 100644index df513a89..00000000--- a/apps/mobile/components/bookmarks/ViewBookmarkModal.tsx+++ /dev/null@@ -1,119 +0,0 @@-import React from "react";-import { Keyboard, Text } from "react-native";-import {- BottomSheetBackdrop,- BottomSheetModal,- BottomSheetModalProps,- BottomSheetScrollView,- BottomSheetView,- TouchableWithoutFeedback,-} from "@gorhom/bottom-sheet";--import { useUpdateBookmark } from "@hoarder/shared-react/hooks/bookmarks";-import { isBookmarkStillTagging } from "@hoarder/shared-react/utils/bookmarkUtils";-import { BookmarkTypes, ZBookmark } from "@hoarder/shared/types/bookmarks";--import { Input } from "../ui/Input";-import PageTitle from "../ui/PageTitle";-import { Skeleton } from "../ui/Skeleton";-import TagPill from "./TagPill";--function TagList({ bookmark }: { bookmark: ZBookmark }) {- return (- <BottomSheetView className="flex flex-row items-center gap-4">- <Text>Tags</Text>- {isBookmarkStillTagging(bookmark) ? (- <>- <Skeleton className="h-4 w-full" />- <Skeleton className="h-4 w-full" />- </>- ) : bookmark.tags.length > 0 ? (- <BottomSheetView className="flex flex-row flex-wrap gap-2">- {bookmark.tags.map((t) => (- <TagPill key={t.id} tag={t} />- ))}- </BottomSheetView>- ) : (- <Text>No tags</Text>- )}- </BottomSheetView>- );-}--function NotesEditor({ bookmark }: { bookmark: ZBookmark }) {- const { mutate, isPending } = useUpdateBookmark();- return (- <BottomSheetView className="flex flex-row items-center gap-4">- <Text>Notes</Text>-- <Input- className="flex-1"- editable={!isPending}- multiline={true}- numberOfLines={3}- loading={isPending}- placeholder="Notes"- textAlignVertical="top"- onEndEditing={(ev) =>- mutate({- bookmarkId: bookmark.id,- note: ev.nativeEvent.text,- })- }- defaultValue={bookmark.note ?? ""}- />- </BottomSheetView>- );-}--const ViewBookmarkModal = React.forwardRef<- BottomSheetModal,- Omit<- BottomSheetModalProps,- "children" | "backdropComponent" | "onDismiss"- > & {- bookmark: ZBookmark;- }->(({ bookmark, ...props }, ref) => {- let title = null;- switch (bookmark.content.type) {- case BookmarkTypes.LINK:- title = bookmark.title ?? bookmark.content.title;- break;- case BookmarkTypes.TEXT:- title = bookmark.title;- break;- case BookmarkTypes.ASSET:- title = bookmark.title ?? bookmark.content.fileName;- break;- }- return (- <BottomSheetModal- ref={ref}- backdropComponent={(props) => (- <BottomSheetBackdrop- appearsOnIndex={0}- disappearsOnIndex={-1}- {...props}- />- )}- {...props}- >- <BottomSheetScrollView className="flex flex-1">- <TouchableWithoutFeedback onPress={Keyboard.dismiss}>- <BottomSheetView className="flex flex-1">- <PageTitle title={title ?? "Untitled"} className="line-clamp-2" />- <BottomSheetView className="gap-4 px-4">- <TagList bookmark={bookmark} />- <NotesEditor bookmark={bookmark} />- </BottomSheetView>- </BottomSheetView>- </TouchableWithoutFeedback>- </BottomSheetScrollView>- </BottomSheetModal>- );-});--ViewBookmarkModal.displayName = "ViewBookmarkModal";--export default ViewBookmarkModal;diff --git a/apps/mobile/components/lists/NewListModal.tsx b/apps/mobile/components/lists/NewListModal.tsxdeleted file mode 100644index d31ac362..00000000--- a/apps/mobile/components/lists/NewListModal.tsx+++ /dev/null@@ -1,80 +0,0 @@-import React, { useState } from "react";-import { Text, View } from "react-native";-import {- BottomSheetBackdrop,- BottomSheetModal,- BottomSheetModalProps,- BottomSheetView,- useBottomSheetModal,-} from "@gorhom/bottom-sheet";--import { useCreateBookmarkList } from "@hoarder/shared-react/hooks/lists";--import { Button } from "../ui/Button";-import { Input } from "../ui/Input";-import PageTitle from "../ui/PageTitle";-import { useToast } from "../ui/Toast";--const NewListModal = React.forwardRef<- BottomSheetModal,- Omit<BottomSheetModalProps, "children" | "backdropComponent" | "onDismiss">->(({ ...props }, ref) => {- const { dismiss } = useBottomSheetModal();- const { toast } = useToast();- const [text, setText] = useState("");-- const { mutate, isPending } = useCreateBookmarkList({- onSuccess: () => {- dismiss();- },- onError: () => {- toast({- message: "Something went wrong",- variant: "destructive",- });- },- });-- const onSubmit = () => {- mutate({- name: text,- icon: "🚀",- });- };-- return (- <View>- <BottomSheetModal- ref={ref}- onDismiss={() => setText("")}- backdropComponent={(props) => (- <BottomSheetBackdrop- appearsOnIndex={0}- disappearsOnIndex={-1}- {...props}- />- )}- {...props}- >- <PageTitle title="New List" />- <BottomSheetView className="gap-2 px-4">- <BottomSheetView className="flex flex-row items-center gap-1">- <Text className="shrink p-2">🚀</Text>- <Input- className="flex-1"- onChangeText={setText}- placeholder="List Name"- autoFocus- autoCapitalize={"none"}- />- </BottomSheetView>- <Button disabled={isPending} onPress={onSubmit} label="Save" />- </BottomSheetView>- </BottomSheetModal>- </View>- );-});--NewListModal.displayName = "NewListModal";--export default NewListModal;diff --git a/apps/mobile/package.json b/apps/mobile/package.jsonindex 3a1322e1..04459dc1 100644--- a/apps/mobile/package.json+++ b/apps/mobile/package.json@@ -13,7 +13,6 @@"typecheck": "tsc --noEmit"},"dependencies": {- "@gorhom/bottom-sheet": "^4.6.3","@hoarder/shared": "workspace:^0.1.0","@hoarder/shared-react": "workspace:^0.1.0","@hoarder/trpc": "workspace:^0.1.0",diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 2a272d71..9640e84c 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -291,9 +291,6 @@ importers:apps/mobile:dependencies:- '@gorhom/bottom-sheet':- specifier: ^4.6.3- version: 4.6.3(@types/[email protected])([email protected]([email protected](@babel/[email protected])(@babel/[email protected](@babel/[email protected]))([email protected]))([email protected]))([email protected](@babel/[email protected])([email protected](@babel/[email protected])(@babel/[email protected](@babel/[email protected]))([email protected]))([email protected]))([email protected](@babel/[email protected])(@babel/[email protected](@babel/[email protected]))([email protected]))([email protected])'@hoarder/shared':specifier: workspace:^0.1.0version: link:../../packages/shared@@ -2762,27 +2759,6 @@ packages:'@ghostery/[email protected]':resolution: {integrity: sha512-FL4yWrpNTCmtbAfeLotUoo94ZyNqHdZpZRo4Qlk0guPzDGcOtW4/c84UzS9D/Z9Z4H3nWSCrW0q38pjwAbDykA==}- '@gorhom/[email protected]':- resolution: {integrity: sha512-fSuSfbtoKsjmSeyz+tG2C0GtcEL7PS63iEXI23c9M+HeCT1IFK6ffmIa2pqyqB43L1jtkR+BWkpZwqXnN4H8xA==}- peerDependencies:- '@types/react': '*'- '@types/react-native': '*'- react: '*'- react-native: '*'- react-native-gesture-handler: '>=1.10.1'- react-native-reanimated: '>=2.2.0'- peerDependenciesMeta:- '@types/react':- optional: true- '@types/react-native':- optional: true-- '@gorhom/[email protected]':- resolution: {integrity: sha512-MXyL4xvCjmgaORr/rtryDNFy3kU4qUbKlwtQqqsygd0xX3mhKjOLn6mQK8wfu0RkoE0pBE0nAasRoHua+/QZ7A==}- peerDependencies:- react: '*'- react-native: '*'-'@graphql-typed-document-node/[email protected]':resolution: {integrity: sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ==}peerDependencies:@@ -16603,24 +16579,6 @@ snapshots:tldts-experimental: 6.1.11dev: false- '@gorhom/[email protected](@types/[email protected])([email protected]([email protected](@babel/[email protected])(@babel/[email protected](@babel/[email protected]))([email protected]))([email protected]))([email protected](@babel/[email protected])([email protected](@babel/[email protected])(@babel/[email protected](@babel/[email protected]))([email protected]))([email protected]))([email protected](@babel/[email protected])(@babel/[email protected](@babel/[email protected]))([email protected]))([email protected])':- dependencies:- '@gorhom/portal': 1.0.14([email protected](@babel/[email protected])(@babel/[email protected](@babel/[email protected]))([email protected]))([email protected])- '@types/react': 18.2.58- invariant: 2.2.4- react: 18.2.0- react-native: 0.73.4(@babel/[email protected])(@babel/[email protected](@babel/[email protected]))([email protected])- react-native-gesture-handler: 2.14.1([email protected](@babel/[email protected])(@babel/[email protected](@babel/[email protected]))([email protected]))([email protected])- react-native-reanimated: 3.8.0(@babel/[email protected])([email protected](@babel/[email protected])(@babel/[email protected](@babel/[email protected]))([email protected]))([email protected])- dev: false-- '@gorhom/[email protected]([email protected](@babel/[email protected])(@babel/[email protected](@babel/[email protected]))([email protected]))([email protected])':- dependencies:- nanoid: 3.3.7- react: 18.2.0- react-native: 0.73.4(@babel/[email protected])(@babel/[email protected](@babel/[email protected]))([email protected])- dev: false-'@graphql-typed-document-node/[email protected]([email protected])':dependencies:graphql: 15.8.0