From cdbb657961c4cad2153075144ff0fc3f3784b9b4 Mon Sep 17 00:00:00 2001 From: Christopher Rossbach <31703168+duncanturk@users.noreply.github.com> Date: Fri, 27 Mar 2020 14:24:42 +0100 Subject: [PATCH] Fix #957 by incrementing the catchup count on home icon. Signed-off-by: Christopher Rossbach <31703168+duncanturk@users.noreply.github.com> --- .../vector/riotx/features/home/HomeDetailViewModel.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/features/home/HomeDetailViewModel.kt b/vector/src/main/java/im/vector/riotx/features/home/HomeDetailViewModel.kt index 6b322a2b48..3824ba7922 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/HomeDetailViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/HomeDetailViewModel.kt @@ -22,6 +22,7 @@ import com.airbnb.mvrx.ViewModelContext import com.squareup.inject.assisted.Assisted import com.squareup.inject.assisted.AssistedInject import im.vector.matrix.android.api.session.Session +import im.vector.matrix.android.api.session.room.model.Membership import im.vector.matrix.rx.rx import im.vector.riotx.core.di.HasScreenInjector import im.vector.riotx.core.platform.EmptyViewEvents @@ -116,10 +117,14 @@ class HomeDetailViewModel @AssistedInject constructor(@Assisted initialState: Ho .observeOn(Schedulers.computation()) .map { it.asSequence() } .subscribe { summaries -> + val invites = summaries + .filter { it.membership == Membership.INVITE } + .count() + val peopleNotifications = summaries .filter { it.isDirect } .map { it.notificationCount } - .sumBy { i -> i } + .sum() val peopleHasHighlight = summaries .filter { it.isDirect } .any { it.highlightCount > 0 } @@ -127,14 +132,14 @@ class HomeDetailViewModel @AssistedInject constructor(@Assisted initialState: Ho val roomsNotifications = summaries .filter { !it.isDirect } .map { it.notificationCount } - .sumBy { i -> i } + .sum() val roomsHasHighlight = summaries .filter { !it.isDirect } .any { it.highlightCount > 0 } setState { copy( - notificationCountCatchup = peopleNotifications + roomsNotifications, + notificationCountCatchup = peopleNotifications + roomsNotifications + invites, notificationHighlightCatchup = peopleHasHighlight || roomsHasHighlight, notificationCountPeople = peopleNotifications, notificationHighlightPeople = peopleHasHighlight,