Browse Source

fixed reloading issues on archive/delete cells

nayooti 5 years ago
parent
commit
a67d7dc536

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

@@ -70,6 +70,10 @@ class ChatListController: UIViewController {
     override func viewWillAppear(_ animated: Bool) {
         super.viewWillAppear(animated)
         updateTitle()
+        // reloading when search active caused a UI-glitch and is actually not needed as long swipe actions are
+        if !viewModel.searchActive {
+            chatTable.reloadData()
+        }
     }
 
     override func viewDidAppear(_ animated: Bool) {
@@ -177,7 +181,6 @@ extension ChatListController: UITableViewDataSource, UITableViewDelegate {
             // default chatCells
             let chatCell = tableView.dequeueReusableCell(withIdentifier: chatCellReuseIdentifier, for: indexPath) as! AvatarTextCell
             let cellViewModel = viewModel.getCellViewModelFor(indexPath: indexPath)
-
             update(avatarCell: chatCell, cellViewModel: cellViewModel)
             return chatCell
         case .CONTACT(let contactData):

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

@@ -63,7 +63,9 @@ class ChatListViewModel: NSObject, ChatListViewModelProtocol {
             .filter { !$0.cellData.isEmpty } //
     }
 
-    private var cellViewModels: [AvatarCellViewModel] = []
+    private var cellViewModels: [AvatarCellViewModel] {
+        return makeUnfilteredCellViewModels()
+    }
 
     func getCellViewModelFor(indexPath: IndexPath) -> AvatarCellViewModel {
         if searchActive {
@@ -91,7 +93,6 @@ class ChatListViewModel: NSObject, ChatListViewModelProtocol {
         self.showArchive = showArchive
         dcContext.updateDeviceChats()
         super.init()
-        cellViewModels = makeUnfilteredCellViewModels()
     }
 
     var numberOfSections: Int {