From 3fa835205e2bb1b51af15b3091be95f8256f1568 Mon Sep 17 00:00:00 2001 From: Sasikanth Miriyampalli Date: Wed, 18 Oct 2023 12:20:01 +0530 Subject: [PATCH] Fix featured section position getting reset after bookmarking a post --- .../kotlin/dev/sasikanth/rss/reader/home/HomePresenter.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/home/HomePresenter.kt b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/home/HomePresenter.kt index 1396f0c31..c74d8422e 100644 --- a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/home/HomePresenter.kt +++ b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/home/HomePresenter.kt @@ -54,6 +54,7 @@ import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.distinctUntilChanged +import kotlinx.coroutines.flow.distinctUntilChangedBy import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.map @@ -219,8 +220,9 @@ class HomePresenter( _state.update { it.copy(selectedFeed = selectedFeed, posts = posts, featuredPosts = featuredPosts) } - effects.tryEmit(HomeEffect.ScrollToTop) } + .distinctUntilChangedBy { (selectedFeed, _, _) -> selectedFeed } + .onEach { effects.tryEmit(HomeEffect.ScrollToTop) } .launchIn(coroutineScope) settingsRepository.enableFeaturedItemBlur