Browse Source

deduplicate code in NotificationManager

cyberta 4 years ago
parent
commit
482249b83d
1 changed files with 4 additions and 9 deletions
  1. 4 9
      deltachat-ios/Helper/NotificationManager.swift

+ 4 - 9
deltachat-ios/Helper/NotificationManager.swift

@@ -100,15 +100,10 @@ public class NotificationManager {
             forName: dcMsgsNoticed,
             object: nil, queue: OperationQueue.main
         ) { notification in
-            DispatchQueue.global(qos: .background).async {
-                if !UserDefaults.standard.bool(forKey: "notifications_disabled") {
-                    NotificationManager.updateApplicationIconBadge(reset: false)
-                    if let ui = notification.userInfo,
-                       let chatId = ui["chat_id"] as? Int {
-                        NotificationManager.removePendingNotificationsFor(chatId: chatId)
-                        NotificationManager.removeDeliveredNotificationsFor(chatId: chatId)
-                    }
-                }
+            if !UserDefaults.standard.bool(forKey: "notifications_disabled"),
+               let ui = notification.userInfo,
+               let chatId = ui["chat_id"] as? Int {
+                NotificationManager.removeNotificationsForChat(chatId: chatId)
             }
         }
     }