From be7311a7db8c9dcc373090b06b825995a3682ee4 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Sun, 31 Aug 2025 16:09:12 +0100 Subject: fix(mobile): Fix text bookmark editor --- apps/mobile/components/bookmarks/BottomActions.tsx | 136 +++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 apps/mobile/components/bookmarks/BottomActions.tsx (limited to 'apps/mobile/components/bookmarks/BottomActions.tsx') diff --git a/apps/mobile/components/bookmarks/BottomActions.tsx b/apps/mobile/components/bookmarks/BottomActions.tsx new file mode 100644 index 00000000..8cfa27c9 --- /dev/null +++ b/apps/mobile/components/bookmarks/BottomActions.tsx @@ -0,0 +1,136 @@ +import { Alert, Linking, Pressable, View } from "react-native"; +import { useRouter } from "expo-router"; +import { TailwindResolver } from "@/components/TailwindResolver"; +import { useToast } from "@/components/ui/Toast"; +import { ClipboardList, Globe, Info, Tag, Trash2 } from "lucide-react-native"; + +import { useDeleteBookmark } from "@karakeep/shared-react/hooks/bookmarks"; +import { BookmarkTypes, ZBookmark } from "@karakeep/shared/types/bookmarks"; + +interface BottomActionsProps { + bookmark: ZBookmark; +} + +export default function BottomActions({ bookmark }: BottomActionsProps) { + const { toast } = useToast(); + const router = useRouter(); + + const { mutate: deleteBookmark, isPending: isDeletionPending } = + useDeleteBookmark({ + onSuccess: () => { + router.back(); + toast({ + message: "The bookmark has been deleted!", + showProgress: false, + }); + }, + onError: () => { + toast({ + message: "Something went wrong", + variant: "destructive", + showProgress: false, + }); + }, + }); + + const deleteBookmarkAlert = () => + Alert.alert( + "Delete bookmark?", + "Are you sure you want to delete this bookmark?", + [ + { text: "Cancel", style: "cancel" }, + { + text: "Delete", + onPress: () => deleteBookmark({ bookmarkId: bookmark.id }), + style: "destructive", + }, + ], + ); + + const actions = [ + { + id: "lists", + icon: ( + } + /> + ), + shouldRender: true, + onClick: () => + router.push(`/dashboard/bookmarks/${bookmark.id}/manage_lists`), + disabled: false, + }, + { + id: "tags", + icon: ( + } + /> + ), + shouldRender: true, + onClick: () => + router.push(`/dashboard/bookmarks/${bookmark.id}/manage_tags`), + disabled: false, + }, + { + id: "open", + icon: ( + } + /> + ), + shouldRender: true, + onClick: () => router.push(`/dashboard/bookmarks/${bookmark.id}/info`), + disabled: false, + }, + { + id: "delete", + icon: ( + } + /> + ), + shouldRender: true, + onClick: deleteBookmarkAlert, + disabled: isDeletionPending, + }, + { + id: "browser", + icon: ( + } + /> + ), + shouldRender: bookmark.content.type == BookmarkTypes.LINK, + onClick: () => + bookmark.content.type == BookmarkTypes.LINK && + Linking.openURL(bookmark.content.url), + disabled: false, + }, + ]; + + return ( + + + {actions.map( + (a) => + a.shouldRender && ( + + {a.icon} + + ), + )} + + + ); +} -- cgit v1.2.3-70-g09d2