Skip to content

Commit

Permalink
Merge pull request #2356 from minvws/bugfix/show-notification-only-on…
Browse files Browse the repository at this point in the history
…ce-per-session
  • Loading branch information
Rool authored Jun 1, 2023
2 parents d98a12b + 326c589 commit b1ce055
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 b1ce055

Please sign in to comment.