This commit is contained in:
Valere 2021-04-26 10:38:38 +02:00
parent dba6784487
commit 45200572a2
3 changed files with 8 additions and 15 deletions

View file

@ -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? {

View file

@ -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)

View file

@ -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) }
}