From 930443ffcf013ca2ab08006c31c81f80e1256949 Mon Sep 17 00:00:00 2001 From: Andrey Chukavin Date: Mon, 18 Sep 2023 11:13:13 +0300 Subject: [PATCH] IOS-4541 Ensure that ViewController only presented once --- TangemSdk/TangemSdk/UI/BaseViewDelegate.swift | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/TangemSdk/TangemSdk/UI/BaseViewDelegate.swift b/TangemSdk/TangemSdk/UI/BaseViewDelegate.swift index 70b46d70c..066dba0c3 100644 --- a/TangemSdk/TangemSdk/UI/BaseViewDelegate.swift +++ b/TangemSdk/TangemSdk/UI/BaseViewDelegate.swift @@ -22,13 +22,11 @@ class BaseViewDelegate { } func presentScreenIfNeeded() { - if screen == nil { - screen = makeScreen() + guard self.screen == nil else { + return } - guard !self.screen!.isBeingPresented, self.screen!.presentingViewController == nil, - let topmostViewController = UIApplication.shared.topMostViewController - else { return } + guard let topmostViewController = UIApplication.shared.topMostViewController else { return } if let presentedController = topmostViewController.presentedViewController { //dismiss alert presentedController.dismiss(animated: false) { @@ -40,7 +38,10 @@ class BaseViewDelegate { return } - topmostViewController.present(self.screen!, animated: true, completion: nil) + let screen = makeScreen() + self.screen = screen + + topmostViewController.present(screen, animated: true, completion: nil) }