File tree Expand file tree Collapse file tree
api/src/main/java/com/getcode/network
app/src/main/java/com/getcode
view/main/scanner/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -123,6 +123,12 @@ class ChatHistoryController @Inject constructor(
123123 .map { it.filter { c -> ! c.isMuted && c.isSubscribed } }
124124 .map { it.sumOf { c -> c.unreadCount } }
125125
126+ val chatUnreadCount = chats
127+ .filterNotNull()
128+ // Ignore muted chats and unsubscribed chats
129+ .map { it.filter { c -> ! c.isMuted && c.isSubscribed } }
130+ .map { it.sumOf { c -> c.unreadCount } }
131+
126132 private fun owner (): KeyPair ? = SessionManager .getKeyPair()
127133
128134 suspend fun fetchChats (update : Boolean = false) {
Original file line number Diff line number Diff line change @@ -157,6 +157,7 @@ data class SessionState(
157157 val isRemoteSendLoading : Boolean = false ,
158158 val splatTipCard : Boolean = false ,
159159 val notificationUnreadCount : Int = 0 ,
160+ val chatUnreadCount : Int = 0 ,
160161 val buyModule : Feature = BuyModuleFeature (),
161162 val requestKin : Feature = RequestKinFeature (),
162163 val cameraGestures : Feature = CameraGesturesFeature (),
@@ -401,6 +402,13 @@ class SessionController @Inject constructor(
401402 state.update { it.copy(notificationUnreadCount = count) }
402403 }.launchIn(scope)
403404
405+ historyController.chatUnreadCount
406+ .distinctUntilChanged()
407+ .map { it }
408+ .onEach { count ->
409+ state.update { it.copy(chatUnreadCount = count) }
410+ }.launchIn(scope)
411+
404412 prefRepository.observeOrDefault(PrefsBool .LOG_SCAN_TIMES , false )
405413 .flowOn(Dispatchers .IO )
406414 .onEach { log ->
Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ internal fun HomeBottom(
9797 modifier = Modifier .weight(1f ),
9898 label = stringResource(R .string.action_chat),
9999 painter = painterResource(R .drawable.ic_chat),
100- badgeCount = 0 ,
100+ badgeCount = state.chatUnreadCount ,
101101 onClick = { onPress(action) },
102102 )
103103 }
You can’t perform that action at this time.
0 commit comments