Try to keep the feed distinct until changed
This commit is contained in:
1 parent
30cd04680c
commit
a116e2de2c
2 files changed
+6
-4
No files matched your search
+3
-2
@@ -35,6 +35,7 @@ import androidx.lifecycle.viewmodel.viewModelFactory
|
|||||||
import co.touchlab.kermit.Logger
|
import co.touchlab.kermit.Logger
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.IO
|
import kotlinx.coroutines.IO
|
||||||
|
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
class FeedListViewModel(
|
class FeedListViewModel(
|
||||||
@@ -60,9 +61,9 @@ class FeedListViewModel(
|
|||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
nostrRepository.observeNostrFeed(
|
nostrRepository.observeNostrFeed(
|
||||||
synchronizationFilter
|
synchronizationFilter
|
||||||
).collect { localNostrEvents ->
|
).distinctUntilChanged().collect { localNostrEvents ->
|
||||||
feedListUIState = FeedListUIState.Loaded(
|
feedListUIState = FeedListUIState.Loaded(
|
||||||
localNostrEvents = localNostrEvents?.filterNotNull() ?: emptyList()
|
localNostrEvents = localNostrEvents
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -26,6 +26,7 @@ import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent
|
|||||||
import com.vitorpamplona.quartz.nip71Video.VideoShortEvent
|
import com.vitorpamplona.quartz.nip71Video.VideoShortEvent
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.IO
|
import kotlinx.coroutines.IO
|
||||||
|
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
enum class SearchResultType {
|
enum class SearchResultType {
|
||||||
@@ -159,9 +160,9 @@ class SearchResultViewModel(
|
|||||||
logger.d("loadSearchResultFeed: $searchQuery")
|
logger.d("loadSearchResultFeed: $searchQuery")
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
// This is something not taking into consideration the results we are actually looking for...
|
// 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(
|
searchResultListUIState = SearchResultListUIState.Loaded(
|
||||||
localNostrEvents = localNostrEvents?.filterNotNull() ?: emptyList()
|
localNostrEvents = localNostrEvents
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user