From b92f2a69700fdc038ff4c45786ae27d65dc8d03f Mon Sep 17 00:00:00 2001 From: Taras Smakula <tarassmakula@gmail.com> Date: Fri, 8 Dec 2023 15:01:10 +0200 Subject: [PATCH] Debounce timeline updates --- .../core/feature/timeline/data_source/BaseTimelineDataSource.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/main/java/org/futo/circles/core/feature/timeline/data_source/BaseTimelineDataSource.kt b/core/src/main/java/org/futo/circles/core/feature/timeline/data_source/BaseTimelineDataSource.kt index 0cceea128..f14aa53d2 100644 --- a/core/src/main/java/org/futo/circles/core/feature/timeline/data_source/BaseTimelineDataSource.kt +++ b/core/src/main/java/org/futo/circles/core/feature/timeline/data_source/BaseTimelineDataSource.kt @@ -5,6 +5,7 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.callbackFlow +import kotlinx.coroutines.flow.debounce import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.mapLatest @@ -57,6 +58,7 @@ abstract class BaseTimelineDataSource( startTimeline(listener) awaitClose() }.flowOn(Dispatchers.IO) + .debounce(150) .mapLatest { val items = timelineBuilder.build(it, isThread) if (it.isNotEmpty() && items.size <= LOAD_MORE_THRESHOLD) loadMore() -- GitLab