Make sure the notification is cancelled

This commit is contained in:
Mygod
2021-07-24 20:36:02 -04:00
parent b03303c73a
commit 403f7c0631

View File

@@ -62,11 +62,9 @@ object ServiceNotification {
} }
} }
fun stopForeground(service: Service) = synchronized(this) { fun stopForeground(service: Service) = synchronized(this) {
deviceCountsMap.remove(service) val shutdown = deviceCountsMap.remove(service) != null && deviceCountsMap.isEmpty()
if (deviceCountsMap.isEmpty()) service.stopForeground(true) else { service.stopForeground(shutdown)
service.stopForeground(false) if (shutdown) manager.cancel(NOTIFICATION_ID) else manager.notify(NOTIFICATION_ID, buildNotification(service))
manager.notify(NOTIFICATION_ID, buildNotification(service))
}
} }
fun updateNotificationChannels() { fun updateNotificationChannels() {