Skip to content

Commit

Permalink
add delete bookmark confirmation dialog for mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
lexafaxine committed Dec 30, 2024
1 parent 59e9fb2 commit a50cac9
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions apps/mobile/components/bookmarks/BookmarkCard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
ActivityIndicator,
Alert,
Image,
Platform,
Pressable,
Expand Down Expand Up @@ -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 />}
Expand All @@ -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,
Expand Down

0 comments on commit a50cac9

Please sign in to comment.