mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-07-25 13:05:19 +00:00
Fix active peer notification in background logic
This commit is contained in:
@@ -178,6 +178,14 @@ class BluetoothMeshService(private val context: Context) {
|
|||||||
try { com.bitchat.android.services.AppStateStore.setPeers(peerIDs) } catch (_: Exception) { }
|
try { com.bitchat.android.services.AppStateStore.setPeers(peerIDs) } catch (_: Exception) { }
|
||||||
// Then notify UI delegate if attached
|
// Then notify UI delegate if attached
|
||||||
delegate?.didUpdatePeerList(peerIDs)
|
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) {
|
override fun onPeerRemoved(peerID: String) {
|
||||||
try { gossipSyncManager.removeAnnouncementForPeer(peerID) } catch (_: Exception) { }
|
try { gossipSyncManager.removeAnnouncementForPeer(peerID) } catch (_: Exception) { }
|
||||||
|
|||||||
@@ -174,6 +174,11 @@ class NotificationManager(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun showActiveUserNotification(peers: List<String>) {
|
fun showActiveUserNotification(peers: List<String>) {
|
||||||
|
if (peers.isEmpty()) {
|
||||||
|
notificationIntervalManager.recentlySeenPeers.clear()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
val currentTime = System.currentTimeMillis()
|
val currentTime = System.currentTimeMillis()
|
||||||
val activePeerNotificationIntervalExceeded =
|
val activePeerNotificationIntervalExceeded =
|
||||||
(currentTime - notificationIntervalManager.lastNetworkNotificationTime) > ACTIVE_PEERS_NOTIFICATION_TIME_INTERVAL
|
(currentTime - notificationIntervalManager.lastNetworkNotificationTime) > ACTIVE_PEERS_NOTIFICATION_TIME_INTERVAL
|
||||||
|
|||||||
Reference in New Issue
Block a user