Skip to content

Commit 516f03b

Browse files
committed
Do not update badges if action or card is hidden
1 parent 57fccdd commit 516f03b

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

SupportCompanion/AppDelegate.swift

+11-5
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,17 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSPopoverDelegate {
167167
}
168168

169169
func setupTrayMenuIconBinding() {
170-
appStateManager.$pendingUpdatesCount
171-
.combineLatest(appStateManager.$systemUpdateCache)
172-
.map { pendingUpdatesCount, systemUpdateCache in
173-
pendingUpdatesCount > 0 || systemUpdateCache.count > 0
174-
}
170+
Publishers.CombineLatest4(
171+
appStateManager.$pendingUpdatesCount,
172+
appStateManager.$systemUpdateCache,
173+
appStateManager.preferences.$hiddenActions,
174+
appStateManager.preferences.$hiddenCards
175+
)
176+
.map { pendingUpdatesCount, systemUpdateCache, hiddenActions, hiddenCards in
177+
let hasPendingUpdates = !hiddenCards.contains("PendingAppUpdates") && pendingUpdatesCount > 0
178+
let hasSoftwareUpdates = !hiddenActions.contains("SoftwareUpdates") && systemUpdateCache.count > 0
179+
return hasPendingUpdates || hasSoftwareUpdates
180+
}
175181
.sink { hasUpdates in
176182
TrayMenuManager.shared.updateTrayIcon(hasUpdates: hasUpdates)
177183
}

SupportCompanion/Services/NotificationService.swift

+4-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,10 @@ class BadgeManager {
155155
private func updateBadge() {
156156
DispatchQueue.main.async {
157157
if self.badgeCount > 0 {
158-
NSApplication.shared.dockTile.showsApplicationBadge = true
158+
let prefs = AppStateManager.shared.preferences
159+
let hasPendingUpdates = !prefs.hiddenCards.contains("PendingAppUpdates") && AppStateManager.shared.pendingUpdatesCount > 0
160+
let hasSoftwareUpdates = !prefs.hiddenActions.contains("SoftwareUpdates") && AppStateManager.shared.systemUpdateCache.count > 0
161+
NSApplication.shared.dockTile.showsApplicationBadge = hasPendingUpdates || hasSoftwareUpdates
159162
NSApplication.shared.dockTile.badgeLabel = nil
160163
NSApplication.shared.dockTile.badgeLabel = String(self.badgeCount)
161164
} else {

0 commit comments

Comments
 (0)