Skip to content

Commit

Permalink
Debounce featured posts updates to avoid UI updating constantly
Browse files Browse the repository at this point in the history
  • Loading branch information
msasikanth committed Oct 2, 2024
1 parent 98f64b5 commit 2d44c04
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down Expand Up @@ -377,6 +379,7 @@ class HomePresenter(
.launchIn(coroutineScope)
}

@OptIn(FlowPreview::class)
private fun loadFeaturedPostsItems(
activeSource: Source?,
unreadOnly: Boolean?,
Expand All @@ -400,6 +403,7 @@ class HomePresenter(
)
}
}
.debounce(500.milliseconds)

private fun feedsSheetStateChanged(feedsSheetState: SheetValue) {
_state.update {
Expand Down

0 comments on commit 2d44c04

Please sign in to comment.