feat: Add total unread count from other chats for back-chevron badge in MainScreen
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user