diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/sync/SyncState.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/sync/SyncState.kt index a2af70f401..cc1c3f1a32 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/sync/SyncState.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/sync/SyncState.kt @@ -18,7 +18,7 @@ package im.vector.matrix.android.api.session.sync sealed class SyncState { object IDLE : SyncState() - data class RUNNING(val catchingUp: Boolean) : SyncState() + data class RUNNING(val afterPause: Boolean) : SyncState() object PAUSED : SyncState() object KILLING : SyncState() object KILLED : SyncState() diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/job/SyncThread.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/job/SyncThread.kt index 6a54ad3331..c08f6101b2 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/job/SyncThread.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/job/SyncThread.kt @@ -37,7 +37,6 @@ import javax.inject.Inject private const val RETRY_WAIT_TIME_MS = 10_000L private const val DEFAULT_LONG_POOL_TIMEOUT = 30_000L -private const val DEFAULT_LONG_POOL_DELAY = 0L internal class SyncThread @Inject constructor(private val syncTask: SyncTask, private val networkConnectivityChecker: NetworkConnectivityChecker, @@ -62,7 +61,7 @@ internal class SyncThread @Inject constructor(private val syncTask: SyncTask, fun restart() = synchronized(lock) { if (state is SyncState.PAUSED) { Timber.v("Resume sync...") - updateStateTo(SyncState.RUNNING(catchingUp = true)) + updateStateTo(SyncState.RUNNING(afterPause = true)) lock.notify() } } @@ -98,7 +97,7 @@ internal class SyncThread @Inject constructor(private val syncTask: SyncTask, } } else { if (state !is SyncState.RUNNING) { - updateStateTo(SyncState.RUNNING(catchingUp = true)) + updateStateTo(SyncState.RUNNING(afterPause = true)) } Timber.v("[$this] Execute sync request with timeout $DEFAULT_LONG_POOL_TIMEOUT") val latch = CountDownLatch(1) @@ -140,11 +139,9 @@ internal class SyncThread @Inject constructor(private val syncTask: SyncTask, latch.await() if (state is SyncState.RUNNING) { - updateStateTo(SyncState.RUNNING(catchingUp = false)) + updateStateTo(SyncState.RUNNING(afterPause = false)) } - Timber.v("Waiting for $DEFAULT_LONG_POOL_DELAY delay before new pool...") - if (DEFAULT_LONG_POOL_DELAY > 0) sleep(DEFAULT_LONG_POOL_DELAY) Timber.v("...Continue") } } diff --git a/vector/src/main/java/im/vector/riotx/features/home/HomeDetailFragment.kt b/vector/src/main/java/im/vector/riotx/features/home/HomeDetailFragment.kt index db8ae35950..bd4b2ca4df 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/HomeDetailFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/HomeDetailFragment.kt @@ -209,7 +209,7 @@ class HomeDetailFragment : VectorBaseFragment(), KeysBackupBanner.Delegate { unreadCounterBadgeViews[INDEX_PEOPLE].render(UnreadCounterBadgeView.State(it.notificationCountPeople, it.notificationHighlightPeople)) unreadCounterBadgeViews[INDEX_ROOMS].render(UnreadCounterBadgeView.State(it.notificationCountRooms, it.notificationHighlightRooms)) syncProgressBar.visibility = when (it.syncState) { - is SyncState.RUNNING -> if (it.syncState.catchingUp) View.VISIBLE else View.GONE + is SyncState.RUNNING -> if (it.syncState.afterPause) View.VISIBLE else View.GONE else -> View.GONE } syncProgressBarWrap.visibility = syncProgressBar.visibility diff --git a/vector/src/main/java/im/vector/riotx/features/home/HomeRoomListObservableStore.kt b/vector/src/main/java/im/vector/riotx/features/home/HomeRoomListObservableStore.kt index 4e0b5b70ed..df8cd411bb 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/HomeRoomListObservableStore.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/HomeRoomListObservableStore.kt @@ -18,10 +18,6 @@ package im.vector.riotx.features.home import im.vector.matrix.android.api.session.room.model.RoomSummary import im.vector.riotx.core.utils.RxStore -import im.vector.riotx.features.home.room.list.RoomListDisplayModeFilter -import im.vector.riotx.features.home.room.list.RoomListFragment -import io.reactivex.Observable -import io.reactivex.schedulers.Schedulers import javax.inject.Inject import javax.inject.Singleton diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomListNameFilter.kt b/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomListNameFilter.kt index e9dd9813b4..7bb5c305aa 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomListNameFilter.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomListNameFilter.kt @@ -18,8 +18,9 @@ package im.vector.riotx.features.home.room.list import im.vector.matrix.android.api.session.room.model.RoomSummary import io.reactivex.functions.Predicate +import javax.inject.Inject -class RoomListNameFilter : Predicate { +class RoomListNameFilter @Inject constructor() : Predicate { var filter: String = "" diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomSummaryController.kt b/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomSummaryController.kt index 97922b8f38..03bedbc7b5 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomSummaryController.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomSummaryController.kt @@ -18,6 +18,7 @@ package im.vector.riotx.features.home.room.list import androidx.annotation.StringRes import com.airbnb.epoxy.TypedEpoxyController +import im.vector.matrix.android.api.session.room.model.Membership import im.vector.matrix.android.api.session.room.model.RoomSummary import im.vector.riotx.core.resources.StringProvider import im.vector.riotx.features.home.room.filtered.FilteredRoomFooterItem @@ -25,13 +26,12 @@ import im.vector.riotx.features.home.room.filtered.filteredRoomFooterItem import javax.inject.Inject class RoomSummaryController @Inject constructor(private val stringProvider: StringProvider, - private val roomSummaryItemFactory: RoomSummaryItemFactory + private val roomSummaryItemFactory: RoomSummaryItemFactory, + private val roomListNameFilter: RoomListNameFilter ) : TypedEpoxyController() { var listener: Listener? = null - private val roomListNameFilter = RoomListNameFilter() - override fun buildModels(viewState: RoomListViewState) { if (viewState.displayMode == RoomListFragment.DisplayMode.FILTERED) { buildFilteredRooms(viewState) @@ -62,7 +62,8 @@ class RoomSummaryController @Inject constructor(private val stringProvider: Stri roomListNameFilter.filter = viewState.roomFilter - val filteredSummaries = summaries.filter { roomListNameFilter.test(it) } + val filteredSummaries = summaries + .filter { it.membership == Membership.JOIN && roomListNameFilter.test(it) } buildRoomModels(filteredSummaries, viewState.joiningRoomsIds,