Bläddra i källkod

tweak archived-link wrt edit-mode (#1785)

* long tapping archived-link does not enter edit-mode

* make archive link unselectable in edit-mode

we access the data directly for speed here;
making viewModel.chatList public is no big deal here
as we are thinking over getting rid of viewModel anyway
(there is already an abstraction layer due to core ffi)

* check for archived-link without db access
bjoern 2 år sedan
förälder
incheckning
f75b693a77

+ 11 - 3
deltachat-ios/Controller/ChatListController.swift

@@ -542,6 +542,11 @@ class ChatListController: UITableViewController {
         viewModel?.setEditing(editing)
     }
 
+    override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
+        guard let viewModel = viewModel, let chatList = viewModel.chatList else { return false }
+        return chatList.getChatId(index: indexPath.row) != DC_CHAT_ID_ARCHIVED_LINK
+    }
+
     func setLongTapEditing(_ editing: Bool, initialIndexPath: [IndexPath]? = nil) {
         setEditing(editing, animated: true)
         if editing {
@@ -895,9 +900,12 @@ extension ChatListController: ContactCellDelegate {
            !searchActive,
            !RelayHelper.shared.isForwarding(),
            !tableView.isEditing {
-            UIImpactFeedbackGenerator(style: .medium).impactOccurred()
-            setLongTapEditing(true, initialIndexPath: [indexPath])
-            tableView.selectRow(at: indexPath, animated: true, scrollPosition: .none)
+            guard let chatList = viewModel?.chatList else { return }
+            if chatList.getChatId(index: indexPath.row) != Int(DC_CHAT_ID_ARCHIVED_LINK) {
+                UIImpactFeedbackGenerator(style: .medium).impactOccurred()
+                setLongTapEditing(true, initialIndexPath: [indexPath])
+                tableView.selectRow(at: indexPath, animated: true, scrollPosition: .none)
+            }
         }
     }
 }

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

@@ -27,7 +27,7 @@ class ChatListViewModel: NSObject {
         return searchActive && searchText.containsCharacters()
     }
 
-    private var chatList: DcChatlist!
+    var chatList: DcChatlist!
 
     // for search filtering
     private var searchText: String = ""