Skip to content

Commit

Permalink
Show the notification only once per session
Browse files Browse the repository at this point in the history
  • Loading branch information
Rool committed May 31, 2023
1 parent d98a12b commit 326c589
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Sources/CTR/Interface/AppCoordinator/AppCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 326c589

Please sign in to comment.