File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed
src/components/PostControls Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import {useCleanError} from '#/lib/hooks/useCleanError'
9
9
import { logger } from '#/logger'
10
10
import { type Shadow } from '#/state/cache/post-shadow'
11
11
import { useBookmarkMutation } from '#/state/queries/bookmarks/useBookmarkMutation'
12
+ import { useRequireAuth } from '#/state/session'
12
13
import { useTheme } from '#/alf'
13
14
import { Bookmark , BookmarkFilled } from '#/components/icons/Bookmark'
14
15
import { Trash_Stroke2_Corner0_Rounded as TrashIcon } from '#/components/icons/Trash'
@@ -30,6 +31,7 @@ export const BookmarkButton = memo(function BookmarkButton({
30
31
const { _} = useLingui ( )
31
32
const { mutateAsync : bookmark } = useBookmarkMutation ( )
32
33
const cleanError = useCleanError ( )
34
+ const requireAuth = useRequireAuth ( )
33
35
34
36
const { viewer} = post
35
37
const isBookmarked = ! ! viewer ?. bookmarked
@@ -108,13 +110,14 @@ export const BookmarkButton = memo(function BookmarkButton({
108
110
}
109
111
}
110
112
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
+ } )
118
121
119
122
return (
120
123
< PostControlButton
You can’t perform that action at this time.
0 commit comments