From 326c589ecf84f6611d4de6d7ef16b822731600a7 Mon Sep 17 00:00:00 2001 From: Rool Paap Date: Wed, 31 May 2023 21:46:32 +0200 Subject: [PATCH] Show the notification only once per session --- .../CTR/Interface/AppCoordinator/AppCoordinator.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Sources/CTR/Interface/AppCoordinator/AppCoordinator.swift b/Sources/CTR/Interface/AppCoordinator/AppCoordinator.swift index e32eeba7d..76b1189b1 100644 --- a/Sources/CTR/Interface/AppCoordinator/AppCoordinator.swift +++ b/Sources/CTR/Interface/AppCoordinator/AppCoordinator.swift @@ -45,6 +45,10 @@ class AppCoordinator: Coordinator { // which can happen with the config being fetched within the TTL. private var isPresentingPriorityNotification = false + // Flag to prevent showing the priority notification dialog twice + // which can happen with the config being fetched within the TTL. + private var hasPresentedPriorityNotification = false + // Flag to prevent showing the recommended update dialog twice // which can happen with the config being fetched within the TTL. private var isPresentingRecommendedUpdate = false @@ -382,8 +386,8 @@ extension AppCoordinator: LaunchStateManagerDelegate { // Only show if the notification is not empty guard notification.isNotEmpty else { return } - // Show only once - guard !isPresentingPriorityNotification else { return } + // prevent presenting twice + guard !isPresentingPriorityNotification, !hasPresentedPriorityNotification else { return } isPresentingPriorityNotification = true @@ -398,6 +402,8 @@ extension AppCoordinator: LaunchStateManagerDelegate { title: L.generalOk(), style: .default, handler: { _ in + // We only want to show this notification once per session + self.hasPresentedPriorityNotification = true self.isPresentingPriorityNotification = false self.priorityNotificationWindow?.alpha = 0 self.priorityNotificationWindow?.isHidden = true