diff options
author | Mary <148872143+mary-ext@users.noreply.github.com> | 2024-02-07 03:26:57 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-06 12:26:57 -0800 |
commit | 41860d8b8084a6ca7af9f7938008eca86a5d08ab (patch) | |
tree | eade0382cef744dc89b6fe6a2f9b47adf69ac560 | |
parent | 2d13f3b3676e42c233e9a1a6436ca7c55ec6388d (diff) | |
download | voidsky-41860d8b8084a6ca7af9f7938008eca86a5d08ab.tar.zst |
fix: remove list from pinned once deleted (#2705)
-rw-r--r-- | src/view/screens/ProfileList.tsx | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/view/screens/ProfileList.tsx b/src/view/screens/ProfileList.tsx index 17c93b037..796464883 100644 --- a/src/view/screens/ProfileList.tsx +++ b/src/view/screens/ProfileList.tsx @@ -55,6 +55,7 @@ import { usePreferencesQuery, usePinFeedMutation, useUnpinFeedMutation, + useSetSaveFeedsMutation, } from '#/state/queries/preferences' import {logger} from '#/logger' import {useAnalytics} from '#/lib/analytics/analytics' @@ -246,9 +247,11 @@ function Header({rkey, list}: {rkey: string; list: AppBskyGraphDefs.ListView}) { useUnpinFeedMutation() const isPending = isPinPending || isUnpinPending const {data: preferences} = usePreferencesQuery() + const {mutate: setSavedFeeds} = useSetSaveFeedsMutation() const {track} = useAnalytics() const isPinned = preferences?.feeds?.pinned?.includes(list.uri) + const isSaved = preferences?.feeds?.saved?.includes(list.uri) const onTogglePinned = React.useCallback(async () => { Haptics.default() @@ -361,6 +364,16 @@ function Header({rkey, list}: {rkey: string; list: AppBskyGraphDefs.ListView}) { message: _(msg`Are you sure?`), async onPressConfirm() { await listDeleteMutation.mutateAsync({uri: list.uri}) + + if (isSaved || isPinned) { + const {saved, pinned} = preferences!.feeds + + setSavedFeeds({ + saved: isSaved ? saved.filter(uri => uri !== list.uri) : saved, + pinned: isPinned ? pinned.filter(uri => uri !== list.uri) : pinned, + }) + } + Toast.show(_(msg`List deleted`)) track('Lists:Delete') if (navigation.canGoBack()) { @@ -370,7 +383,18 @@ function Header({rkey, list}: {rkey: string; list: AppBskyGraphDefs.ListView}) { } }, }) - }, [openModal, list, listDeleteMutation, navigation, track, _]) + }, [ + openModal, + list, + listDeleteMutation, + navigation, + track, + _, + preferences, + isPinned, + isSaved, + setSavedFeeds, + ]) const onPressReport = useCallback(() => { openModal({ |