From dd00a3a7658bc236f941d036c037002c5b1dc1b4 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Mon, 25 Aug 2025 18:11:01 -0500 Subject: [PATCH] Add toasts --- .../PostControls/BookmarkButton.tsx | 20 +++++++++++-------- src/screens/Bookmarks/index.tsx | 11 +++++----- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/components/PostControls/BookmarkButton.tsx b/src/components/PostControls/BookmarkButton.tsx index 558f4fcc6c..c32b660804 100644 --- a/src/components/PostControls/BookmarkButton.tsx +++ b/src/components/PostControls/BookmarkButton.tsx @@ -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 ( @@ -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({