Fix top level unread counts

Apparently, one combined flow doesn't seem to update - which doesn't
matter, since we don't need it (compared to upstream). So fix it by
cleaning things up.

Change-Id: I6f9c8802abadf1bb27cc35e9cb5f1a48850aa347
This commit is contained in:
SpiritCroc 2021-11-24 10:15:37 +01:00
parent a036601e0c
commit 205828852d

View file

@ -58,7 +58,7 @@ data class CountInfo(
class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initialState: UnreadMessagesState, class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initialState: UnreadMessagesState,
session: Session, session: Session,
private val vectorPreferences: VectorPreferences, private val vectorPreferences: VectorPreferences,
appStateHandler: AppStateHandler, //appStateHandler: AppStateHandler,
private val autoAcceptInvites: AutoAcceptInvites) : private val autoAcceptInvites: AutoAcceptInvites) :
VectorViewModel<UnreadMessagesState, EmptyAction, EmptyViewEvents>(initialState) { VectorViewModel<UnreadMessagesState, EmptyAction, EmptyViewEvents>(initialState) {
@ -107,6 +107,14 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initia
) )
} }
session.getPagedRoomSummariesLive(
roomSummaryQueryParams {
this.memberships = Membership.activeMemberships()
}, sortOrder = RoomSortOrder.NONE
).asFlow()
.throttleFirst(300)
.execute {
/*
combine( combine(
appStateHandler.selectedRoomGroupingObservable.distinctUntilChanged(), appStateHandler.selectedRoomGroupingObservable.distinctUntilChanged(),
appStateHandler.selectedRoomGroupingObservable.flatMapLatest { appStateHandler.selectedRoomGroupingObservable.flatMapLatest {
@ -128,6 +136,7 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initia
} }
is RoomGroupingMethod.BySpace -> { is RoomGroupingMethod.BySpace -> {
//val selectedSpace = appStateHandler.safeActiveSpaceId() //val selectedSpace = appStateHandler.safeActiveSpaceId()
*/
val inviteCount = if (autoAcceptInvites.hideInvites) { val inviteCount = if (autoAcceptInvites.hideInvites) {
0 0
@ -164,6 +173,7 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initia
totalCount.unreadCount totalCount.unreadCount
) )
// SC: count total room notifications for drawer badge, instead of filtering for others like Element does, // SC: count total room notifications for drawer badge, instead of filtering for others like Element does,
// to prevent counting rooms multiple times // to prevent counting rooms multiple times
val topLevelTotalCount = if (spacesShowAllRoomsInHome) { val topLevelTotalCount = if (spacesShowAllRoomsInHome) {
@ -183,7 +193,11 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initia
topLevelTotalCount.unreadCount topLevelTotalCount.unreadCount
) )
CountInfo(homeCount = counts, otherCount = topLevelCounts) copy(
homeSpaceUnread = counts,
otherSpacesUnread = topLevelCounts
)
//CountInfo(homeCount = counts, otherCount = topLevelCounts)
/* /*
val rootCounts = session.spaceService().getRootSpaceSummaries() val rootCounts = session.spaceService().getRootSpaceSummaries()
@ -208,6 +222,7 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initia
) )
) )
*/ */
/*
} }
null -> { null -> {
CountInfo( CountInfo(
@ -223,6 +238,7 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initia
homeSpaceUnread = it.invoke()?.homeCount ?: RoomAggregateNotificationCount(0, 0, 0), homeSpaceUnread = it.invoke()?.homeCount ?: RoomAggregateNotificationCount(0, 0, 0),
otherSpacesUnread = it.invoke()?.otherCount ?: RoomAggregateNotificationCount(0, 0, 0) otherSpacesUnread = it.invoke()?.otherCount ?: RoomAggregateNotificationCount(0, 0, 0)
) )
*/
} }
} }
} }