From ce19fd36d39df3a53028a118795e2c8d380b0420 Mon Sep 17 00:00:00 2001 From: Philippe Weidmann Date: Thu, 1 Feb 2024 14:35:32 +0100 Subject: [PATCH 1/2] fix: Delay DefaultDiscoveryView after ComposeView dismiss --- Mail/Views/New Message/ComposeMessageView.swift | 5 ++++- MailCore/UI/UIConstants.swift | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Mail/Views/New Message/ComposeMessageView.swift b/Mail/Views/New Message/ComposeMessageView.swift index 11e20f13f..a7cae5ee3 100644 --- a/Mail/Views/New Message/ComposeMessageView.swift +++ b/Mail/Views/New Message/ComposeMessageView.swift @@ -316,7 +316,10 @@ struct ComposeMessageView: View { sendDraft() if !Bundle.main.isExtension { - mainViewState.isShowingSetAppAsDefaultDiscovery = UserDefaults.shared.shouldPresentSetAsDefaultDiscovery + // We should implement a proper router to avoid doing this + DispatchQueue.main.asyncAfter(deadline: UIConstants.modalCloseDelay) { + mainViewState.isShowingSetAppAsDefaultDiscovery = UserDefaults.shared.shouldPresentSetAsDefaultDiscovery + } if !mainViewState.isShowingSetAppAsDefaultDiscovery { mainViewState.isShowingChristmasEasterEgg = true } diff --git a/MailCore/UI/UIConstants.swift b/MailCore/UI/UIConstants.swift index 8c3104e18..0b75e7f45 100644 --- a/MailCore/UI/UIConstants.swift +++ b/MailCore/UI/UIConstants.swift @@ -116,6 +116,10 @@ public extension UIConstants { public extension UIConstants { static let checkboxAppearDelay = 0.2 static let checkboxDisappearOffsetDelay = 0.35 + + static var modalCloseDelay: DispatchTime { + DispatchTime.now() + 0.75 + } } // MARK: - Utils From ed864fa2864b768d519563ca2d467db2ec99ea38 Mon Sep 17 00:00:00 2001 From: Philippe Weidmann Date: Mon, 5 Feb 2024 08:34:23 +0100 Subject: [PATCH 2/2] fix: Add delay also for print --- MailCore/Cache/Actions/ActionsManager.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MailCore/Cache/Actions/ActionsManager.swift b/MailCore/Cache/Actions/ActionsManager.swift index 7f28030b0..e7fea90de 100644 --- a/MailCore/Cache/Actions/ActionsManager.swift +++ b/MailCore/Cache/Actions/ActionsManager.swift @@ -149,7 +149,7 @@ public class ActionsManager: ObservableObject { case .print: guard let message = messages.first else { return } // Needed to be sure that the bottomView is dismissed before we try to show the printPanel - DispatchQueue.main.asyncAfter(deadline: .now() + 1) { + DispatchQueue.main.asyncAfter(deadline: UIConstants.modalCloseDelay) { let nc = NotificationCenter.default nc.post(name: Notification.Name.printNotification, object: message) }