From 91b6334d3403fd001a1f27c0ceb3cf74dcf8fc56 Mon Sep 17 00:00:00 2001 From: Christophe Deschamps Date: Thu, 21 Jul 2022 12:14:49 +0200 Subject: [PATCH] Fix Toast not dismissing --- Classes/Swift/Voip/VoipDialog.swift | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Classes/Swift/Voip/VoipDialog.swift b/Classes/Swift/Voip/VoipDialog.swift index 696e8d190..055ded827 100644 --- a/Classes/Swift/Voip/VoipDialog.swift +++ b/Classes/Swift/Voip/VoipDialog.swift @@ -91,18 +91,29 @@ class VoipDialog : UIView{ } private static func rootVC() -> UIViewController? { - return UIApplication.getTopMostViewController() + return PhoneMainView.instance().mainViewController } required init?(coder: NSCoder) { super.init(coder: coder) } + static var toastQueue: [String] = [] + static func toast(message:String, timeout:CGFloat = 1.5) { + if (toastQueue.count > 0) { + toastQueue.append(message) + return + } let alert = UIAlertController(title: nil, message: message, preferredStyle: .actionSheet) rootVC()?.present(alert, animated: true) DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + timeout) { - alert.dismiss(animated: true) + alert.dismiss(animated: true) + if (toastQueue.count > 0) { + let message = toastQueue.first + toastQueue.remove(at: 0) + self.toast(message: message!) + } } }