diff --git a/app/src/main/java/com/bitchat/android/mesh/BluetoothMeshService.kt b/app/src/main/java/com/bitchat/android/mesh/BluetoothMeshService.kt index 474c04a5..86a24bd3 100644 --- a/app/src/main/java/com/bitchat/android/mesh/BluetoothMeshService.kt +++ b/app/src/main/java/com/bitchat/android/mesh/BluetoothMeshService.kt @@ -178,6 +178,14 @@ class BluetoothMeshService(private val context: Context) { try { com.bitchat.android.services.AppStateStore.setPeers(peerIDs) } catch (_: Exception) { } // Then notify UI delegate if attached delegate?.didUpdatePeerList(peerIDs) + + // If UI is detached (background), update notification manager directly + if (delegate == null) { + try { + serviceNotificationManager.setAppBackgroundState(true) + serviceNotificationManager.showActiveUserNotification(peerIDs) + } catch (_: Exception) { } + } } override fun onPeerRemoved(peerID: String) { try { gossipSyncManager.removeAnnouncementForPeer(peerID) } catch (_: Exception) { } diff --git a/app/src/main/java/com/bitchat/android/ui/NotificationManager.kt b/app/src/main/java/com/bitchat/android/ui/NotificationManager.kt index 9eb72b48..f905c61b 100644 --- a/app/src/main/java/com/bitchat/android/ui/NotificationManager.kt +++ b/app/src/main/java/com/bitchat/android/ui/NotificationManager.kt @@ -174,6 +174,11 @@ class NotificationManager( } fun showActiveUserNotification(peers: List) { + if (peers.isEmpty()) { + notificationIntervalManager.recentlySeenPeers.clear() + return + } + val currentTime = System.currentTimeMillis() val activePeerNotificationIntervalExceeded = (currentTime - notificationIntervalManager.lastNetworkNotificationTime) > ACTIVE_PEERS_NOTIFICATION_TIME_INTERVAL