From a6a314989969bcec8b93af827ca09278e9cba363 Mon Sep 17 00:00:00 2001 From: Zafir Sk Heerah Date: Wed, 26 Jun 2024 15:41:56 +0400 Subject: [PATCH] Async fixes --- src/ios/CDVRoomPlan.swift | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/ios/CDVRoomPlan.swift b/src/ios/CDVRoomPlan.swift index 990f651..70e156b 100644 --- a/src/ios/CDVRoomPlan.swift +++ b/src/ios/CDVRoomPlan.swift @@ -89,22 +89,26 @@ class CDVRoomPlan: CDVPlugin, RoomCaptureSessionDelegate, RoomCaptureViewDelegat self.activityIndicator?.stopAnimating() } + func dismissCaptureView() { + self.activityIndicator?.stopAnimating() + stopSession() + roomCaptureView.removeFromSuperview() + NotificationCenter.default.removeObserver(self) + } + @objc func doneScanning(_ sender: UIButton) { if state == "scanning" { stopSession() self.activityIndicator?.startAnimating() } else if state == "done" { exportResults() - cancelScanning(sender) + dismissCaptureView() } } @objc func cancelScanning(_ sender: UIButton) { - self.activityIndicator?.stopAnimating() - stopSession() - roomCaptureView.removeFromSuperview() - NotificationCenter.default.removeObserver(self) - let result = ["cancelled": true, "message": "Scanning cancelled"] + dismissCaptureView() + let result = ["message": "Scanning cancelled"] let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: result) pluginResult?.keepCallback = true self.commandDelegate.send(pluginResult, callbackId: self.command.callbackId)