Selaa lähdekoodia

direct calling of popViewController, target comment of @nayooti

B. Petersen 5 vuotta sitten
vanhempi
commit
9ee81243aa

+ 1 - 5
deltachat-ios/Controller/AccountSetupController.swift

@@ -797,7 +797,7 @@ class AccountSetupController: UITableViewController, ProgressAlertHandler {
         if let onLoginSuccess = self.onLoginSuccess {
             onLoginSuccess()
         } else {
-            self.navigateBack()
+            navigationController?.popViewController(animated: true)
         }
     }
 
@@ -867,10 +867,6 @@ class AccountSetupController: UITableViewController, ProgressAlertHandler {
         guard let url = URL(string: provider.getOverviewPage) else { return }
         UIApplication.shared.open(url)
     }
-
-    private func navigateBack() {
-        navigationController?.popViewController(animated: true)
-    }
 }
 
 // MARK: - UITextFieldDelegate

+ 2 - 6
deltachat-ios/Controller/ChatViewController.swift

@@ -582,7 +582,7 @@ class ChatViewController: MessagesViewController {
         case NSSelectorFromString("messageForward:"):
             let msg = messageList[indexPath.section]
             RelayHelper.sharedInstance.setForwardMessage(messageId: msg.id)
-            navigateBack()
+            navigationController?.popViewController(animated: true)
         default:
             super.collectionView(collectionView, performAction: action, forItemAt: indexPath, withSender: sender)
         }
@@ -635,15 +635,11 @@ class ChatViewController: MessagesViewController {
                             self.dismiss(animated: true, completion: nil)},
                           cancelHandler: { _ in
                             self.dismiss(animated: false, completion: nil)
-                            self.navigateBack()})
+                            self.navigationController?.popViewController(animated: true)})
         }
     }
 
     // MARK: - coordinator
-    private func navigateBack() {
-        navigationController?.popViewController(animated: true)
-    }
-
     private func showChatDetail(chatId: Int) {
         let chat = dcContext.getChat(chatId: chatId)
         switch chat.chatType {

+ 1 - 1
deltachat-ios/Controller/EditContactController.swift

@@ -30,7 +30,7 @@ class EditContactController: NewContactController {
 
     @objc override func saveContactButtonPressed() {
         _ = dcContext.createContact(name: model.name, email: model.email)
-        navigateBack()
+        navigationController?.popViewController(animated: true)
     }
 
 }

+ 2 - 7
deltachat-ios/Controller/EditGroupViewController.swift

@@ -86,11 +86,11 @@ class EditGroupViewController: UITableViewController, MediaPickerDelegate {
             AvatarHelper.saveChatAvatar(dcContext: dcContext, image: groupImage, for: Int(chat.id))
         }
         _ = dcContext.setChatName(chatId: chat.id, name: newName ?? "")
-        navigateBack()
+        navigationController?.popViewController(animated: true)
     }
 
     @objc func cancelButtonPressed() {
-        navigateBack()
+        navigationController?.popViewController(animated: true)
     }
 
     private func groupNameEdited(_ textField: UITextField) {
@@ -129,9 +129,4 @@ class EditGroupViewController: UITableViewController, MediaPickerDelegate {
         self.tableView.reloadRows(at: [indexPath], with: UITableView.RowAnimation.none)
         self.tableView.endUpdates()
     }
-
-    // MARK: - coordinator
-    private func navigateBack() {
-        navigationController?.popViewController(animated: true)
-    }
 }

+ 2 - 6
deltachat-ios/Controller/NewContactController.swift

@@ -77,12 +77,12 @@ class NewContactController: UITableViewController {
         if openChatOnSave {
             showChat(chatId: chatId)
         } else {
-            navigateBack()
+            navigationController?.popViewController(animated: true)
         }
     }
 
     @objc func cancelButtonPressed() {
-        navigateBack()
+        navigationController?.popViewController(animated: true)
     }
 
     required init?(coder _: NSCoder) {
@@ -100,10 +100,6 @@ class NewContactController: UITableViewController {
     }
 
     // MARK: - coordinator
-    func navigateBack() {
-        navigationController?.popViewController(animated: true)
-    }
-
     private func showChat(chatId: Int) {
         if let chatlistViewController = navigationController?.viewControllers[0] {
             let chatViewController = ChatViewController(dcContext: dcContext, chatId: chatId)

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

@@ -46,7 +46,7 @@ class ContactDetailViewModel: ContactDetailViewModelProtocol {
         return DcContact(id: contactId)
     }
 
-    internal let chatId: Int?
+    let chatId: Int?
     private let sharedChats: DcChatlist
     private var sections: [ProfileSections] = []
     private var chatActions: [ChatAction] = [] // chatDetail: archive, block, delete - else: block