diff --git a/app/src/main/java/com/rosetta/messenger/MainActivity.kt b/app/src/main/java/com/rosetta/messenger/MainActivity.kt index 656a3ff..8845d81 100644 --- a/app/src/main/java/com/rosetta/messenger/MainActivity.kt +++ b/app/src/main/java/com/rosetta/messenger/MainActivity.kt @@ -971,6 +971,17 @@ fun MainScreen( // 🔒 Lock swipe-back while chat overlays are open (image viewer/editor/media picker/camera). var isChatSwipeLocked by remember { mutableStateOf(false) } + // 🔴 Badge: total unread from OTHER chats (excluding current) for back-chevron badge + val totalUnreadFromOthers by remember(accountPublicKey, selectedUser?.publicKey) { + val db = RosettaDatabase.getDatabase(context) + val opponentKey = selectedUser?.publicKey ?: "" + if (accountPublicKey.isNotBlank() && opponentKey.isNotBlank()) { + db.dialogDao().getTotalUnreadCountExcludingFlow(accountPublicKey, opponentKey) + } else { + kotlinx.coroutines.flow.flowOf(0) + } + }.collectAsState(initial = 0) + SwipeBackContainer( isVisible = selectedUser != null, onBack = { popChatAndChildren() }, @@ -984,6 +995,7 @@ fun MainScreen( currentUserPublicKey = accountPublicKey, currentUserPrivateKey = accountPrivateKey, currentUserName = accountName, + totalUnreadFromOthers = totalUnreadFromOthers, onBack = { popChatAndChildren() }, onUserProfileClick = { user -> if (user.publicKey == accountPublicKey) {