From effc428673021b07801803c094ee0dc353c5d41d Mon Sep 17 00:00:00 2001 From: kp-laura-sempere <46663952+kp-laura-sempere@users.noreply.github.com> Date: Thu, 10 Oct 2024 10:25:53 +0200 Subject: [PATCH] KM-5043: Dismiss any other view that is presented before presenting Force Update screen (#172) --- PIA VPN/DashboardViewController.swift | 15 ++++++++++++++- PIA VPN/PIAWelcomeViewController.swift | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/PIA VPN/DashboardViewController.swift b/PIA VPN/DashboardViewController.swift index 15dbf182..c1cc246c 100644 --- a/PIA VPN/DashboardViewController.swift +++ b/PIA VPN/DashboardViewController.swift @@ -706,7 +706,20 @@ class DashboardViewController: AutolayoutViewController { let forceUpdate = ForceUpdateViewController() forceUpdate.modalPresentationStyle = .fullScreen DispatchQueue.main.async { [weak self] in - self?.present(forceUpdate, animated: false) + var isOtherViewPresented = false + if let presented = self?.presentedViewController { + if !(presented is ForceUpdateViewController) { + isOtherViewPresented = true + } + } + + if isOtherViewPresented { + self?.dismiss(animated: false, completion: { + self?.present(forceUpdate, animated: false) + }) + } else { + self?.present(forceUpdate, animated: false) + } } } diff --git a/PIA VPN/PIAWelcomeViewController.swift b/PIA VPN/PIAWelcomeViewController.swift index 822d4add..722a0c1a 100644 --- a/PIA VPN/PIAWelcomeViewController.swift +++ b/PIA VPN/PIAWelcomeViewController.swift @@ -209,7 +209,20 @@ public class PIAWelcomeViewController: AutolayoutViewController, WelcomeCompleti let forceUpdate = ForceUpdateViewController() forceUpdate.modalPresentationStyle = .fullScreen DispatchQueue.main.async { [weak self] in - self?.present(forceUpdate, animated: false) + var isOtherViewPresented = false + if let presented = self?.presentedViewController { + if !(presented is ForceUpdateViewController) { + isOtherViewPresented = true + } + } + + if isOtherViewPresented { + self?.dismiss(animated: false, completion: { + self?.present(forceUpdate, animated: false) + }) + } else { + self?.present(forceUpdate, animated: false) + } } }