Browse Source

remove now superfluous blocking join-progress-dialog

B. Petersen 3 years ago
parent
commit
99534f0fb6
2 changed files with 7 additions and 66 deletions
  1. 0 19
      DcCore/DcCore/DC/events.swift
  2. 7 47
      deltachat-ios/Controller/QrPageController.swift

+ 0 - 19
DcCore/DcCore/DC/events.swift

@@ -5,7 +5,6 @@ public let dcNotificationChanged = Notification.Name(rawValue: "MrEventMsgsChang
 public let dcNotificationIncoming = Notification.Name(rawValue: "MrEventIncomingMsg")
 public let dcNotificationImexProgress = Notification.Name(rawValue: "dcNotificationImexProgress")
 public let dcNotificationConfigureProgress = Notification.Name(rawValue: "MrEventConfigureProgress")
-public let dcNotificationSecureJoinerProgress = Notification.Name(rawValue: "MrEventSecureJoinerProgress")
 public let dcNotificationSecureInviterProgress = Notification.Name(rawValue: "MrEventSecureInviterProgress")
 public let dcNotificationContactChanged = Notification.Name(rawValue: "MrEventContactsChanged")
 public let dcNotificationChatModified = Notification.Name(rawValue: "dcNotificationChatModified")
@@ -194,24 +193,6 @@ public class DcEventHandler {
                 )
             }
 
-        case DC_EVENT_SECUREJOIN_JOINER_PROGRESS:
-            if dcContext.id != dcAccounts.getSelected().id {
-                return
-            }
-            dcContext.logger?.info("securejoin joiner progress \(data1)")
-            let nc = NotificationCenter.default
-            DispatchQueue.main.async {
-                nc.post(
-                    name: dcNotificationSecureJoinerProgress,
-                    object: nil,
-                    userInfo: [
-                        "contact_id": Int(data1),
-                        "progress": Int(data2),
-                        "error": Int(data2) == 0,
-                        "done": Int(data2) == 1000,
-                    ]
-                )
-            }
         case DC_EVENT_CONTACTS_CHANGED:
             if dcContext.id != dcAccounts.getSelected().id {
                 return

+ 7 - 47
deltachat-ios/Controller/QrPageController.swift

@@ -1,9 +1,8 @@
 import UIKit
 import DcCore
 
-class QrPageController: UIPageViewController, ProgressAlertHandler {
+class QrPageController: UIPageViewController {
     private let dcContext: DcContext
-    weak var progressAlert: UIAlertController?
     var progressObserver: NSObjectProtocol?
     var qrCodeReaderController: QrCodeReaderController?
 
@@ -288,24 +287,12 @@ extension QrPageController: QrCodeReaderDelegate {
                                       preferredStyle: .alert)
         alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .default, handler: nil))
         alert.addAction(UIAlertAction(title: String.localized("ok"), style: .default, handler: { _ in
-            alert.dismiss(animated: true, completion: nil)
-            self.showProgressAlert(title: String.localized("one_moment")+"\n\n", dcContext: self.dcContext)
-            // execute blocking secure join in background
-            DispatchQueue.global(qos: .background).async {
-                self.addSecureJoinProgressListener()
-                self.dcContext.lastErrorString = nil
-                let chatId = self.dcContext.joinSecurejoin(qrCode: code)
-                let errorString = self.dcContext.lastErrorString
-                self.removeSecureJoinProgressListener()
-
-                DispatchQueue.main.async {
-                    self.progressAlert?.dismiss(animated: true, completion: nil)
-                    if chatId != 0 {
-                        self.showChat(chatId: chatId)
-                    } else if errorString != nil {
-                        self.showErrorAlert(error: errorString!)
-                    }
-                }
+            self.dcContext.lastErrorString = nil
+            let chatId = self.dcContext.joinSecurejoin(qrCode: code)
+            if chatId != 0 {
+                self.showChat(chatId: chatId)
+            } else {
+                self.showErrorAlert(error: self.dcContext.lastErrorString ?? "ErrJoinNoString")
             }
         }))
         present(alert, animated: true, completion: nil)
@@ -317,31 +304,4 @@ extension QrPageController: QrCodeReaderDelegate {
             alert.dismiss(animated: true, completion: nil)
         }))
     }
-
-    private func addSecureJoinProgressListener() {
-        let nc = NotificationCenter.default
-        progressObserver = nc.addObserver(
-            forName: dcNotificationSecureJoinerProgress,
-            object: nil,
-            queue: nil
-        ) { [weak self] notification in
-            guard let self = self else { return }
-            if let ui = notification.userInfo,
-                ui["progress"] as? Int == 400,
-                let contactId = ui["contact_id"] as? Int {
-                self.progressAlert?.message = String.localizedStringWithFormat(
-                    String.localized("qrscan_x_verified_introduce_myself"),
-                    self.dcContext.getContact(id: contactId).nameNAddr
-                )
-            }
-        }
-    }
-
-    private func removeSecureJoinProgressListener() {
-        let nc = NotificationCenter.default
-        if let observer = self.progressObserver {
-            nc.removeObserver(observer)
-        }
-    }
-
 }