From 917256713f7c811413ec9d305a56c65aae58fd6e Mon Sep 17 00:00:00 2001
From: Samuel Newman <mozzius@protonmail.com>
Date: Fri, 5 Sep 2025 17:31:25 +0300
Subject: require auth for bookmarks (#8983)

---
 src/components/PostControls/BookmarkButton.tsx | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

(limited to 'src/components/PostControls/BookmarkButton.tsx')

diff --git a/src/components/PostControls/BookmarkButton.tsx b/src/components/PostControls/BookmarkButton.tsx
index 70acebc05..f72951520 100644
--- a/src/components/PostControls/BookmarkButton.tsx
+++ b/src/components/PostControls/BookmarkButton.tsx
@@ -9,6 +9,7 @@ import {useCleanError} from '#/lib/hooks/useCleanError'
 import {logger} from '#/logger'
 import {type Shadow} from '#/state/cache/post-shadow'
 import {useBookmarkMutation} from '#/state/queries/bookmarks/useBookmarkMutation'
+import {useRequireAuth} from '#/state/session'
 import {useTheme} from '#/alf'
 import {Bookmark, BookmarkFilled} from '#/components/icons/Bookmark'
 import {Trash_Stroke2_Corner0_Rounded as TrashIcon} from '#/components/icons/Trash'
@@ -30,6 +31,7 @@ export const BookmarkButton = memo(function BookmarkButton({
   const {_} = useLingui()
   const {mutateAsync: bookmark} = useBookmarkMutation()
   const cleanError = useCleanError()
+  const requireAuth = useRequireAuth()
 
   const {viewer} = post
   const isBookmarked = !!viewer?.bookmarked
@@ -108,13 +110,14 @@ export const BookmarkButton = memo(function BookmarkButton({
     }
   }
 
-  const onHandlePress = async () => {
-    if (isBookmarked) {
-      await remove()
-    } else {
-      await save()
-    }
-  }
+  const onHandlePress = () =>
+    requireAuth(async () => {
+      if (isBookmarked) {
+        await remove()
+      } else {
+        await save()
+      }
+    })
 
   return (
     <PostControlButton
-- 
cgit 1.4.1

