Try to keep the feed distinct until changed

This commit is contained in:
Kgothatso Ngako
2026-05-02 03:27:22 +02:00
parent 30cd04680c
commit a116e2de2c
2 changed files with 6 additions and 4 deletions

View File

@@ -35,6 +35,7 @@ import androidx.lifecycle.viewmodel.viewModelFactory
import co.touchlab.kermit.Logger
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.IO
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.launch
class FeedListViewModel(
@@ -60,9 +61,9 @@ class FeedListViewModel(
viewModelScope.launch(Dispatchers.IO) {
nostrRepository.observeNostrFeed(
synchronizationFilter
).collect { localNostrEvents ->
).distinctUntilChanged().collect { localNostrEvents ->
feedListUIState = FeedListUIState.Loaded(
localNostrEvents = localNostrEvents?.filterNotNull() ?: emptyList()
localNostrEvents = localNostrEvents
)
}
}

View File

@@ -26,6 +26,7 @@ import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent
import com.vitorpamplona.quartz.nip71Video.VideoShortEvent
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.IO
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.launch
enum class SearchResultType {
@@ -159,9 +160,9 @@ class SearchResultViewModel(
logger.d("loadSearchResultFeed: $searchQuery")
viewModelScope.launch(Dispatchers.IO) {
// This is something not taking into consideration the results we are actually looking for...
nostrRepository.observeNostrFeed(synchronizationFilter).collect { localNostrEvents ->
nostrRepository.observeNostrFeed(synchronizationFilter).distinctUntilChanged().collect { localNostrEvents ->
searchResultListUIState = SearchResultListUIState.Loaded(
localNostrEvents = localNostrEvents?.filterNotNull() ?: emptyList()
localNostrEvents = localNostrEvents
)
}
}