Parcourir la source

delete notifications if chat has been archived

cyberta il y a 4 ans
Parent
commit
537345c578

+ 3 - 0
deltachat-ios/Controller/GroupChatDetailViewController.swift

@@ -255,6 +255,9 @@ class GroupChatDetailViewController: UIViewController {
 
     private func toggleArchiveChat() {
         let archivedBefore = chat.isArchived
+        if (!archivedBefore) {
+            NotificationManager.removeNotificationsForChat(chatId: chatId)
+        }
         dcContext.archiveChat(chatId: chat.id, archive: !archivedBefore)
         if archivedBefore {
             archiveChatCell.actionTitle = String.localized("menu_archive_chat")

+ 5 - 1
deltachat-ios/ViewModel/ChatListViewModel.swift

@@ -182,7 +182,11 @@ class ChatListViewModel: NSObject {
 
     func archiveChatToggle(chatId: Int) {
         let chat = dcContext.getChat(chatId: chatId)
-        dcContext.archiveChat(chatId: chatId, archive: !chat.isArchived)
+        let isArchivedBefore = chat.isArchived
+        if (!isArchivedBefore) {
+            NotificationManager.removeNotificationsForChat(chatId: chatId)
+        }
+        dcContext.archiveChat(chatId: chatId, archive: !isArchivedBefore)
         updateChatList(notifyListener: false)
     }
 

+ 5 - 1
deltachat-ios/ViewModel/ContactDetailViewModel.swift

@@ -164,7 +164,11 @@ class ContactDetailViewModel {
             safe_fatalError("there is no chatId - you are probably are calling this from ContactDetail - this should be only called from ChatDetail")
             return false
         }
-        context.archiveChat(chatId: chatId, archive: !chatIsArchived)
+        let isArchivedBefore = chatIsArchived
+        if !isArchivedBefore {
+            NotificationManager.removeNotificationsForChat(chatId: chatId)
+        }
+        context.archiveChat(chatId: chatId, archive: !isArchivedBefore)
         return chatIsArchived
     }
 }