feat: Add total unread count from other chats for back-chevron badge in MainScreen

This commit is contained in:
2026-02-24 21:04:27 +05:00
parent 6643e0e069
commit 75810a0696

View File

@@ -971,6 +971,17 @@ fun MainScreen(
// 🔒 Lock swipe-back while chat overlays are open (image viewer/editor/media picker/camera). // 🔒 Lock swipe-back while chat overlays are open (image viewer/editor/media picker/camera).
var isChatSwipeLocked by remember { mutableStateOf(false) } 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( SwipeBackContainer(
isVisible = selectedUser != null, isVisible = selectedUser != null,
onBack = { popChatAndChildren() }, onBack = { popChatAndChildren() },
@@ -984,6 +995,7 @@ fun MainScreen(
currentUserPublicKey = accountPublicKey, currentUserPublicKey = accountPublicKey,
currentUserPrivateKey = accountPrivateKey, currentUserPrivateKey = accountPrivateKey,
currentUserName = accountName, currentUserName = accountName,
totalUnreadFromOthers = totalUnreadFromOthers,
onBack = { popChatAndChildren() }, onBack = { popChatAndChildren() },
onUserProfileClick = { user -> onUserProfileClick = { user ->
if (user.publicKey == accountPublicKey) { if (user.publicKey == accountPublicKey) {