From f476fca758bb039f9605488b61ba35fc097d6cfc Mon Sep 17 00:00:00 2001
From: Nicole Li <40200356+lexafaxine@users.noreply.github.com>
Date: Tue, 31 Dec 2024 19:33:41 +0900
Subject: feat: Add delete bookmark confirmation dialog. Fixes #776  (#787)

---
 apps/mobile/components/bookmarks/BookmarkCard.tsx | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

(limited to 'apps/mobile/components/bookmarks/BookmarkCard.tsx')

diff --git a/apps/mobile/components/bookmarks/BookmarkCard.tsx b/apps/mobile/components/bookmarks/BookmarkCard.tsx
index 13d639c9..ce294a6f 100644
--- a/apps/mobile/components/bookmarks/BookmarkCard.tsx
+++ b/apps/mobile/components/bookmarks/BookmarkCard.tsx
@@ -1,5 +1,6 @@
 import {
   ActivityIndicator,
+  Alert,
   Image,
   Platform,
   Pressable,
@@ -70,6 +71,20 @@ function ActionBar({ bookmark }: { bookmark: ZBookmark }) {
       onError,
     });
 
+  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",
+        },
+      ],
+    );
+
   return (
     <View className="flex flex-row gap-4">
       {(isArchivePending || isDeletionPending) && <ActivityIndicator />}
@@ -93,9 +108,7 @@ function ActionBar({ bookmark }: { bookmark: ZBookmark }) {
         onPressAction={({ nativeEvent }) => {
           Haptics.selectionAsync();
           if (nativeEvent.event === "delete") {
-            deleteBookmark({
-              bookmarkId: bookmark.id,
-            });
+            deleteBookmarkAlert();
           } else if (nativeEvent.event === "archive") {
             archiveBookmark({
               bookmarkId: bookmark.id,
-- 
cgit v1.2.3-70-g09d2

