From bae5921de78d69e326cc3eb2b60a34f0e08baa3c Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Tue, 9 Feb 2021 18:04:17 +0100 Subject: [PATCH] Unify dm and group categories in unread notifications tab Note: this does not automatically update when the user toggles the unified list on/off, but unread notifications tab is a lab feature either way, and the user impact is probably negligible. Change-Id: I4dcdb0a6800493a7b5a5053ae4f4e8f7fa89f7fb --- .../app/features/home/room/list/RoomListViewModel.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt index e8097f9cf6..44e2d3ffe2 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt @@ -25,6 +25,7 @@ import im.vector.app.core.extensions.exhaustive import im.vector.app.core.platform.VectorViewModel import im.vector.app.core.utils.DataSource import im.vector.app.features.home.RoomListDisplayMode +import im.vector.app.features.settings.VectorPreferences import io.reactivex.schedulers.Schedulers import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -46,6 +47,8 @@ class RoomListViewModel @Inject constructor(initialState: RoomListViewState, private val roomSummariesSource: DataSource>) : VectorViewModel(initialState) { + private var vectorPreferences: VectorPreferences? = null + interface Factory { fun create(initialState: RoomListViewState): RoomListViewModel } @@ -68,6 +71,7 @@ class RoomListViewModel @Inject constructor(initialState: RoomListViewState, } fun initWithContext(context: Context, displayMode: RoomListDisplayMode) { + vectorPreferences = VectorPreferences(context) setState { // RoomListViewState.initWithContext this.initWithContext(context, displayMode) @@ -292,10 +296,11 @@ class RoomListViewModel @Inject constructor(initialState: RoomListViewState, } } } + val vectorPreferences = this.vectorPreferences return RoomSummaries().apply { put(RoomCategory.INVITE, invites) put(RoomCategory.FAVOURITE, favourites) - if (displayMode == RoomListDisplayMode.ALL) { + if (displayMode == RoomListDisplayMode.ALL || vectorPreferences?.combinedOverview() == true) { put(RoomCategory.COMBINED, normalPriority) } else { put(RoomCategory.DIRECT, directChats)