瀏覽代碼

Merge pull request #1179 from deltachat/delete_saved_messages

fix app crash if saved messages chat gets deleted
cyBerta 4 年之前
父節點
當前提交
6228b72d48
共有 2 個文件被更改,包括 3 次插入10 次删除
  1. 1 2
      deltachat-ios/Controller/ChatListController.swift
  2. 2 8
      deltachat-ios/ViewModel/ChatListViewModel.swift

+ 1 - 2
deltachat-ios/Controller/ChatListController.swift

@@ -463,8 +463,7 @@ class ChatListController: UITableViewController {
             return
         }
 
-        let row = viewModel.deleteChat(chatId: chatId)
-        tableView.deleteRows(at: [IndexPath(row: row, section: 0)], with: .fade)
+        viewModel.deleteChat(chatId: chatId)
     }
 
     // MARK: - coordinator

+ 2 - 8
deltachat-ios/ViewModel/ChatListViewModel.swift

@@ -22,8 +22,7 @@ protocol ChatListViewModelProtocol: class, UISearchResultsUpdating {
     func titleForHeaderIn(section: Int) -> String? // only visible on search results
     var emptySearchText: String? { get }
 
-    /// returns ROW of table
-    func deleteChat(chatId: Int) -> Int
+    func deleteChat(chatId: Int)
     func archiveChatToggle(chatId: Int)
     func pinChatToggle(chatId: Int)
     func refreshData()
@@ -201,13 +200,8 @@ class ChatListViewModel: NSObject, ChatListViewModelProtocol {
         return nil
     }
 
-    func deleteChat(chatId: Int) -> Int {
-        // find index of chatId
-        let indexToDelete = Array(0..<chatList.length).filter { chatList.getChatId(index: $0) == chatId }.first
+    func deleteChat(chatId: Int) {
         dcContext.deleteChat(chatId: chatId)
-        updateChatList(notifyListener: false)
-        safe_assert(indexToDelete != nil)
-        return indexToDelete ?? -1
     }
 
     func archiveChatToggle(chatId: Int) {