From 45200572a2f30bd7ac32c1c2a8928ee9ff43dd97 Mon Sep 17 00:00:00 2001 From: Valere Date: Mon, 26 Apr 2021 10:38:38 +0200 Subject: [PATCH] Cleaning --- .../main/java/im/vector/app/AppStateHandler.kt | 18 ++++++------------ .../room/list/GroupRoomListSectionBuilder.kt | 2 +- .../features/spaces/SpaceSummaryController.kt | 3 +-- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/vector/src/main/java/im/vector/app/AppStateHandler.kt b/vector/src/main/java/im/vector/app/AppStateHandler.kt index ce6a274e09..0df41d106d 100644 --- a/vector/src/main/java/im/vector/app/AppStateHandler.kt +++ b/vector/src/main/java/im/vector/app/AppStateHandler.kt @@ -22,7 +22,6 @@ import androidx.lifecycle.OnLifecycleEvent import arrow.core.Option import im.vector.app.core.di.ActiveSessionHolder import im.vector.app.core.utils.BehaviorDataSource -import im.vector.app.features.settings.VectorPreferences import im.vector.app.features.ui.UiStateRepository import io.reactivex.disposables.CompositeDisposable import kotlinx.coroutines.GlobalScope @@ -51,8 +50,7 @@ fun RoomGroupingMethod.group() = (this as? RoomGroupingMethod.ByLegacyGroup)?.gr class AppStateHandler @Inject constructor( sessionDataSource: ActiveSessionDataSource, private val uiStateRepository: UiStateRepository, - private val activeSessionHolder: ActiveSessionHolder, - vectorPreferences: VectorPreferences + private val activeSessionHolder: ActiveSessionHolder ) : LifecycleObserver { private val compositeDisposable = CompositeDisposable() @@ -100,18 +98,14 @@ class AppStateHandler @Inject constructor( // sessionDataSource could already return a session while acitveSession holder still returns null it.orNull()?.let { session -> if (uiStateRepository.isGroupingMethodSpace(session.sessionId)) { - uiStateRepository.getSelectedSpace(session.sessionId).let { selectedSpaceId -> - setCurrentSpace(selectedSpaceId, session) - } + setCurrentSpace(uiStateRepository.getSelectedSpace(session.sessionId), session) } else { - uiStateRepository.getSelectedGroup(session.sessionId).let { selectedGroupId -> - setCurrentGroup(selectedGroupId, session) - } + setCurrentGroup(uiStateRepository.getSelectedGroup(session.sessionId), session) } } - }.also { - compositeDisposable.add(it) - } + }.also { + compositeDisposable.add(it) + } } fun safeActiveSpaceId(): String? { diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/GroupRoomListSectionBuilder.kt b/vector/src/main/java/im/vector/app/features/home/room/list/GroupRoomListSectionBuilder.kt index 6287ef58e0..22b0eb091c 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/GroupRoomListSectionBuilder.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/GroupRoomListSectionBuilder.kt @@ -100,7 +100,7 @@ class GroupRoomListSectionBuilder( appStateHandler.selectedRoomGroupingObservable .distinctUntilChanged() .subscribe { groupingMethod -> - val selectedGroupId = (groupingMethod as? RoomGroupingMethod.ByLegacyGroup)?.groupSummary?.groupId + val selectedGroupId = (groupingMethod.orNull() as? RoomGroupingMethod.ByLegacyGroup)?.groupSummary?.groupId activeGroupAwareQueries.onEach { updater -> updater.updateQuery { query -> query.copy(activeGroupId = selectedGroupId) diff --git a/vector/src/main/java/im/vector/app/features/spaces/SpaceSummaryController.kt b/vector/src/main/java/im/vector/app/features/spaces/SpaceSummaryController.kt index 8a1529493d..c3e730f29e 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/SpaceSummaryController.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/SpaceSummaryController.kt @@ -136,10 +136,9 @@ class SpaceSummaryController @Inject constructor( } } - val isSelected = selected is RoomGroupingMethod.BySpace && selected.space() == null homeSpaceSummaryItem { id("space_home") - selected(isSelected) + selected(selected is RoomGroupingMethod.BySpace && selected.space() == null) countState(UnreadCounterBadgeView.State(homeCount.totalCount, homeCount.isHighlight)) listener { callback?.onSpaceSelected(null) } }