From d1ffea543202d6625570920b5c80e0ade3c791d4 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Wed, 12 Jul 2023 10:20:24 -0400 Subject: [PATCH] BugFix for a race condition when deleting events. --- .../com/vitorpamplona/amethyst/ui/screen/FeedViewModel.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/FeedViewModel.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/FeedViewModel.kt index c632d9e5c..c13af964c 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/FeedViewModel.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/FeedViewModel.kt @@ -259,12 +259,12 @@ abstract class FeedViewModel(val localFilter: FeedFilter) : ViewModel(), I val oldNotesState = _feedContent.value if (localFilter is AdditiveFeedFilter && lastFeedKey == localFilter.feedKey()) { if (oldNotesState is FeedState.Loaded) { - val newList = localFilter.updateListWith(oldNotesState.feed.value, newItems.toSet()).toImmutableList() + val newList = localFilter.updateListWith(oldNotesState.feed.value, newItems.toSet()).distinctBy { it.idHex }.toImmutableList() if (!equalImmutableLists(newList, oldNotesState.feed.value)) { updateFeed(newList) } } else if (oldNotesState is FeedState.Empty) { - val newList = localFilter.updateListWith(emptyList(), newItems.toSet()).toImmutableList() + val newList = localFilter.updateListWith(emptyList(), newItems.toSet()).distinctBy { it.idHex }.toImmutableList() if (newList.isNotEmpty()) { updateFeed(newList) }