From 31c884402697c7edadcb1f535bccced988e816a2 Mon Sep 17 00:00:00 2001 From: Narasimha-sc <166327228+Narasimha-sc@users.noreply.github.com> Date: Sun, 18 Oct 2026 02:13:33 +0000 Subject: [PATCH] desktop: show unread count in window title The main window title becomes "SimpleX [N]" while there are unread messages the user would be notified about: the active profile's chats by their notification mode, and other non-hidden, non-muted profiles' unread counts. --- .../kotlin/chat/simplex/common/DesktopApp.kt | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/DesktopApp.kt b/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/DesktopApp.kt index 77dad81aa4..db2c3b62eb 100644 --- a/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/DesktopApp.kt +++ b/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/DesktopApp.kt @@ -120,6 +120,22 @@ private fun ApplicationScope.AppWindow(closedByError: MutableState) { } simplexWindowState.windowState = windowState + val unreadTotal by remember { + derivedStateOf { + val active = ChatModel.chats.value.sumOf { c -> + when (c.chatInfo.chatSettings?.enableNtfs) { + MsgFilter.All -> c.chatStats.unreadCount + MsgFilter.Mentions -> minOf(c.chatStats.unreadMentions, c.chatStats.unreadCount) + else -> 0 + } + } + val others = ChatModel.users.sumOf { u -> + if (!u.user.activeUser && !u.user.hidden && u.user.showNtfs) u.unreadCount else 0 + } + active + others + } + } + val windowTitle = if (unreadTotal > 0) "SimpleX [$unreadTotal]" else "SimpleX" // Reload all strings in all @Composable's after language change at runtime if (remember { ChatController.appPrefs.appLanguage.state }.value != "") { Window(state = windowState, visible = simplexWindowState.windowVisible.value, icon = painterResource(MR.images.ic_simplex), onCloseRequest = { handleCloseRequest(closedByError) }, onKeyEvent = { @@ -128,7 +144,7 @@ private fun ApplicationScope.AppWindow(closedByError: MutableState) { } else { false } - }, title = "SimpleX") { + }, title = windowTitle) { // val hardwareAccelerationDisabled = remember { listOf(GraphicsApi.SOFTWARE_FAST, GraphicsApi.SOFTWARE_COMPAT, GraphicsApi.UNKNOWN).contains(window.renderApi) } simplexWindowState.window = window AppScreen()