Add toasts

This commit is contained in:
Eric Bailey
2025-08-25 18:11:01 -05:00
parent 969557d118
commit dd00a3a765
2 changed files with 18 additions and 13 deletions
+12 -8
View File
@@ -9,6 +9,7 @@ import {type Shadow} from '#/state/cache/post-shadow'
import {useBookmarkMutation} from '#/state/queries/bookmarks/useBookmarkMutation'
import {useTheme} from '#/alf'
import {Bookmark, BookmarkFilled} from '#/components/icons/Bookmark'
import * as toast from '#/components/Toast'
import {PostControlButton, PostControlButtonIcon} from './PostControlButton'
export const BookmarkButton = memo(function BookmarkButton({
@@ -33,21 +34,24 @@ export const BookmarkButton = memo(function BookmarkButton({
action: 'delete',
uri,
})
// TODO toast
toast.show(_(msg`Removed from saved posts`))
} else {
await bookmark({
action: 'create',
uri,
cid,
})
// TODO toast
toast.show(_(msg`Post saved`), {
type: 'success',
})
}
} catch (e) {
} catch (e: any) {
const {raw, clean} = cleanError(e)
console.log(clean || raw || e)
// TODO toast
toast.show(clean || raw || e, {
type: 'error',
})
}
}, [uri, cid, isBookmarked, bookmark, cleanError])
}, [_, uri, cid, isBookmarked, bookmark, cleanError])
return (
<PostControlButton
@@ -55,8 +59,8 @@ export const BookmarkButton = memo(function BookmarkButton({
big={big}
label={
isBookmarked
? _(msg`Remove this post from your bookmarks`)
: _(msg`Save this post to your bookmarks`)
? _(msg`Remove from saved posts`)
: _(msg`Add to saved posts`)
}
onPress={onHandlePress}>
<PostControlButtonIcon
+6 -5
View File
@@ -31,6 +31,7 @@ import {CircleQuestion_Stroke2_Corner2_Rounded as QuestionIcon} from '#/componen
import * as Layout from '#/components/Layout'
import {ListFooter} from '#/components/Lists'
import * as Skele from '#/components/Skeleton'
import * as toast from '#/components/Toast'
import {Text} from '#/components/Typography'
type Props = NativeStackScreenProps<CommonNavigatorParams, 'Bookmarks'>
@@ -114,7 +115,6 @@ function BookmarksInner() {
const onEndReached = useCallback(async () => {
if (isFetchingNextPage || !hasNextPage || error) return
try {
console.log('Fetching more bookmarks...')
await fetchNextPage()
} catch {}
}, [isFetchingNextPage, hasNextPage, error, fetchNextPage])
@@ -220,10 +220,11 @@ function BookmarkNotFound({
try {
setRemoved(true)
await bookmark({action: 'delete', uri: post.uri})
} catch (e) {
} catch (e: any) {
const {raw, clean} = cleanError(e)
console.log(clean || raw || e)
// TODO toast
toast.show(clean || raw || e, {
type: 'error',
})
}
}, [post.uri, bookmark, cleanError])
@@ -260,7 +261,7 @@ function BookmarkNotFound({
</Text>
</View>
<Button
label={_(msg`Remove this post from your bookmarks`)}
label={_(msg`Remove from saved posts`)}
size="tiny"
color="secondary"
onPress={remove}>