From 020a2f3923e875757224bbb916417c7e853bb036 Mon Sep 17 00:00:00 2001 From: ganfra Date: Thu, 31 Jan 2019 12:13:51 +0100 Subject: [PATCH] Room list : add some throttle to avoid refreshing too often. --- .../features/home/room/list/RoomListViewModel.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/list/RoomListViewModel.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/list/RoomListViewModel.kt index d8edf515..68d41bae 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/list/RoomListViewModel.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/list/RoomListViewModel.kt @@ -33,6 +33,7 @@ import io.reactivex.Observable import io.reactivex.functions.Function3 import io.reactivex.rxkotlin.subscribeBy import org.koin.android.ext.android.get +import java.util.concurrent.TimeUnit typealias RoomListFilterName = CharSequence @@ -95,9 +96,9 @@ class RoomListViewModel(initialState: RoomListViewState, private fun observeRoomSummaries() { Observable.combineLatest, Option, Option, RoomSummaries>( - session.rx().liveRoomSummaries(), + session.rx().liveRoomSummaries().throttleLast(300, TimeUnit.MILLISECONDS), selectedGroupHolder.selectedGroup(), - roomListFilter, + roomListFilter.throttleLast(300, TimeUnit.MILLISECONDS), Function3 { rooms, selectedGroupOption, filterRoomOption -> val filteredRooms = filterRooms(rooms, filterRoomOption) val selectedGroup = selectedGroupOption.orNull()