From 108d8a2e57529d546e4e31b784196495fe4f3ef6 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Wed, 27 Aug 2025 08:00:08 -0400 Subject: [PATCH] Improves draft deletes in the feeds --- .../ui/feeds/ChannelFeedContentState.kt | 2 ++ .../loggedIn/AccountFeedContentStates.kt | 28 +++++++++++++++++++ .../ui/screen/loggedIn/AccountViewModel.kt | 1 + .../notifications/CardFeedContentState.kt | 3 ++ 4 files changed, 34 insertions(+) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/ChannelFeedContentState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/ChannelFeedContentState.kt index fa561cbf6..c49976e69 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/ChannelFeedContentState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/ChannelFeedContentState.kt @@ -105,6 +105,8 @@ class ChannelFeedContentState( } } + fun deleteFromFeed(deletedNotes: Set) {} + fun refreshFromOldState(newItems: Set) { val oldNotesState = _feedContent.value if (oldNotesState is ChannelFeedState.Loaded) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountFeedContentStates.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountFeedContentStates.kt index 962a1009d..2264d833f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountFeedContentStates.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountFeedContentStates.kt @@ -104,6 +104,34 @@ class AccountFeedContentStates( drafts.updateFeedWith(newNotes) } + fun deleteNotes(newNotes: Set) { + checkNotInMainThread() + + homeLive.deleteFromFeed(newNotes) + homeNewThreads.deleteFromFeed(newNotes) + homeReplies.deleteFromFeed(newNotes) + + dmKnown.updateFeedWith(newNotes) + dmNew.updateFeedWith(newNotes) + + videoFeed.deleteFromFeed(newNotes) + + discoverMarketplace.deleteFromFeed(newNotes) + discoverFollowSets.deleteFromFeed(newNotes) + discoverReads.deleteFromFeed(newNotes) + discoverDVMs.deleteFromFeed(newNotes) + discoverLive.deleteFromFeed(newNotes) + discoverCommunities.deleteFromFeed(newNotes) + discoverPublicChats.deleteFromFeed(newNotes) + + notifications.deleteFromFeed(newNotes) + notificationSummary.invalidateInsertData(newNotes) + + feedListOptions.deleteFromFeed(newNotes) + + drafts.deleteFromFeed(newNotes) + } + fun destroy() { notifications.destroy() notificationSummary.destroy() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt index 1b853709b..3e7c758de 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt @@ -1193,6 +1193,7 @@ class AccountViewModel( } logTime("AccountViewModel deletedEventBundle Update with ${newNotes.size} new notes") { newNotesPreProcessor.runDeleted(newNotes) + feedStates.deleteNotes(newNotes) } } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedContentState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedContentState.kt index a22766245..175e0bec9 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedContentState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedContentState.kt @@ -340,6 +340,9 @@ class CardFeedContentState( } } + fun deleteFromFeed(deletedNotes: Set) { + } + private fun refreshFromOldState(newItems: Set) { val oldNotesState = _feedContent.value