Try to keep the feed distinct until changed
This commit is contained in:
@@ -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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user