From 2d44c04dc5a4d22a2e60df65b6c2d095474e9ffd Mon Sep 17 00:00:00 2001 From: Sasikanth Miriyampalli Date: Wed, 2 Oct 2024 08:26:26 +0530 Subject: [PATCH] Debounce featured posts updates to avoid UI updating constantly --- .../kotlin/dev/sasikanth/rss/reader/home/HomePresenter.kt | 4 ++++ 1 file changed, 4 insertions(+) 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 4522fff8..d5738313 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 @@ -45,9 +45,11 @@ import dev.sasikanth.rss.reader.util.DispatchersProvider import dev.sasikanth.rss.reader.utils.NTuple4 import dev.sasikanth.rss.reader.utils.getLast24HourStart import dev.sasikanth.rss.reader.utils.getTodayStartInstant +import kotlin.time.Duration.Companion.milliseconds import kotlinx.collections.immutable.toImmutableList import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.cancel import kotlinx.coroutines.flow.* @@ -377,6 +379,7 @@ class HomePresenter( .launchIn(coroutineScope) } + @OptIn(FlowPreview::class) private fun loadFeaturedPostsItems( activeSource: Source?, unreadOnly: Boolean?, @@ -400,6 +403,7 @@ class HomePresenter( ) } } + .debounce(500.milliseconds) private fun feedsSheetStateChanged(feedsSheetState: SheetValue) { _state.update {