diff options
author | Samuel Newman <mozzius@protonmail.com> | 2025-09-05 17:31:25 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-09-05 09:31:25 -0500 |
commit | 917256713f7c811413ec9d305a56c65aae58fd6e (patch) | |
tree | 184bd16d2875751416ee03f24621675800b055ce /src | |
parent | c26906e15c72b80f0f4c5b33a42101b53e722071 (diff) | |
download | voidsky-917256713f7c811413ec9d305a56c65aae58fd6e.tar.zst |
require auth for bookmarks (#8983)
Diffstat (limited to 'src')
-rw-r--r-- | src/components/PostControls/BookmarkButton.tsx | 17 |
1 files changed, 10 insertions, 7 deletions
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 |