From b927574b7b7d8e2f9d4495c3413a87d6886f3260 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Sun, 24 Aug 2025 16:08:01 +0300 Subject: feat: Add delete button and creation dates to mobile info page --- .../mobile/app/dashboard/bookmarks/[slug]/info.tsx | 111 +++++++++++++++------ 1 file changed, 78 insertions(+), 33 deletions(-) (limited to 'apps/mobile') diff --git a/apps/mobile/app/dashboard/bookmarks/[slug]/info.tsx b/apps/mobile/app/dashboard/bookmarks/[slug]/info.tsx index b79a50b2..af124160 100644 --- a/apps/mobile/app/dashboard/bookmarks/[slug]/info.tsx +++ b/apps/mobile/app/dashboard/bookmarks/[slug]/info.tsx @@ -1,5 +1,6 @@ import React from "react"; import { + Alert, Keyboard, Pressable, Text, @@ -13,13 +14,17 @@ import Animated, { import { router, Stack, useLocalSearchParams } from "expo-router"; import TagPill from "@/components/bookmarks/TagPill"; import FullPageError from "@/components/FullPageError"; +import { Button } from "@/components/ui/Button"; +import { Divider } from "@/components/ui/Divider"; import FullPageSpinner from "@/components/ui/FullPageSpinner"; import { Input } from "@/components/ui/Input"; import { Skeleton } from "@/components/ui/Skeleton"; +import { useToast } from "@/components/ui/Toast"; import { ChevronRight } from "lucide-react-native"; import { useAutoRefreshingBookmarkQuery, + useDeleteBookmark, useUpdateBookmark, } from "@karakeep/shared-react/hooks/bookmarks"; import { BookmarkTypes, ZBookmark } from "@karakeep/shared/types/bookmarks"; @@ -27,33 +32,33 @@ import { isBookmarkStillTagging } from "@karakeep/shared/utils/bookmarkUtils"; function TagList({ bookmark }: { bookmark: ZBookmark }) { return ( - - Tags - - {isBookmarkStillTagging(bookmark) ? ( - - - - - ) : bookmark.tags.length > 0 ? ( - - {bookmark.tags.map((t) => ( - - ))} - - ) : ( - 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 - - - + + {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 px-4" + > + Manage Tags + + ); } @@ -61,7 +66,6 @@ function TagList({ bookmark }: { bookmark: ZBookmark }) { function ManageLists({ bookmark }: { bookmark: ZBookmark }) { return ( - Lists router.push(`/dashboard/bookmarks/${bookmark.id}/manage_lists`) @@ -85,8 +89,6 @@ function TitleEditor({ const { mutate, isPending } = useUpdateBookmark(); return ( - Title - - Notes - { const { slug } = useLocalSearchParams(); + const { toast } = useToast(); if (typeof slug !== "string") { throw new Error("Unexpected param type"); } + const { mutate: deleteBookmark, isPending: isDeletionPending } = + useDeleteBookmark({ + onSuccess: () => { + router.replace("dashboard"); + toast({ + message: "The bookmark has been deleted!", + showProgress: false, + }); + }, + }); + const keyboard = useAnimatedKeyboard(); const animatedStyles = useAnimatedStyle(() => ({ @@ -161,6 +173,21 @@ const ViewBookmarkPage = () => { ); } + const handleDeleteBookmark = () => { + 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", + }, + ], + ); + }; + let title = null; switch (bookmark.content.type) { case BookmarkTypes.LINK: @@ -197,11 +224,29 @@ const ViewBookmarkPage = () => { /> - + +