nayooti 5 лет назад
Родитель
Сommit
fa5fbadc7b

+ 25 - 4
deltachat-ios/Controller/ChatListController.swift

@@ -64,7 +64,7 @@ class ChatListController: UIViewController {
 
         deleteChatObserver = nc.addObserver(forName: dcNotificationChatDeletedInChatDetail, object: nil, queue: nil) { notification in
             if let chatId = notification.userInfo?["chat_id"] as? Int {
-                self.deleteChat(chatId: chatId)
+                self.deleteChat(chatId: chatId, animated: true)
             }
         }
     }
@@ -307,14 +307,35 @@ extension ChatListController: UITableViewDataSource, UITableViewDelegate {
             preferredStyle: .safeActionSheet
         )
         alert.addAction(UIAlertAction(title: String.localized("menu_delete_chat"), style: .destructive, handler: { _ in
-            self.deleteChat(chatId: chatId)
+            self.deleteChat(chatId: chatId, animated: true)
         }))
         alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel, handler: nil))
         self.present(alert, animated: true, completion: nil)
     }
 
-    private func deleteChat(chatId: Int) {
+    private func deleteChat(chatId: Int, animated: Bool) {
         self.dcContext.deleteChat(chatId: chatId)
-        self.getChatList()
+        if !animated {
+            self.getChatList()
+            return
+        }
+
+        guard let chatList = chatList else {
+            return
+        }
+
+        // find index of chatId
+        let index = Array(0..<chatList.length).filter { chatList.getChatId(index: $0) == chatId }.first
+
+        guard let row = index else {
+            return
+        }
+
+        var gclFlags: Int32 = 0
+        if showArchive {
+            gclFlags |= DC_GCL_ARCHIVED_ONLY
+        }
+        self.chatList = dcContext.getChatlist(flags: gclFlags, queryString: nil, queryId: 0)
+        chatTable.deleteRows(at: [IndexPath(row: row, section: 0)], with: .fade)    
     }
 }

+ 1 - 0
deltachat-ios/Coordinator/AppCoordinator.swift

@@ -608,6 +608,7 @@ class ContactDetailCoordinator: Coordinator, ContactDetailCoordinatorProtocol {
 
         // we want to notify chatList to delete chat AFTER is is visible
         CATransaction.begin()
+        CATransaction.setAnimationDuration(2)
         CATransaction.setCompletionBlock(notifyToDeleteChat)
         self.navigationController.popToRootViewController(animated: true)
         CATransaction.commit()