Skip to content

Commit 9172567

Browse files
authored
require auth for bookmarks (#8983)
1 parent c26906e commit 9172567

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/components/PostControls/BookmarkButton.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {useCleanError} from '#/lib/hooks/useCleanError'
99
import {logger} from '#/logger'
1010
import {type Shadow} from '#/state/cache/post-shadow'
1111
import {useBookmarkMutation} from '#/state/queries/bookmarks/useBookmarkMutation'
12+
import {useRequireAuth} from '#/state/session'
1213
import {useTheme} from '#/alf'
1314
import {Bookmark, BookmarkFilled} from '#/components/icons/Bookmark'
1415
import {Trash_Stroke2_Corner0_Rounded as TrashIcon} from '#/components/icons/Trash'
@@ -30,6 +31,7 @@ export const BookmarkButton = memo(function BookmarkButton({
3031
const {_} = useLingui()
3132
const {mutateAsync: bookmark} = useBookmarkMutation()
3233
const cleanError = useCleanError()
34+
const requireAuth = useRequireAuth()
3335

3436
const {viewer} = post
3537
const isBookmarked = !!viewer?.bookmarked
@@ -108,13 +110,14 @@ export const BookmarkButton = memo(function BookmarkButton({
108110
}
109111
}
110112

111-
const onHandlePress = async () => {
112-
if (isBookmarked) {
113-
await remove()
114-
} else {
115-
await save()
116-
}
117-
}
113+
const onHandlePress = () =>
114+
requireAuth(async () => {
115+
if (isBookmarked) {
116+
await remove()
117+
} else {
118+
await save()
119+
}
120+
})
118121

119122
return (
120123
<PostControlButton

0 commit comments

Comments
 (0)