You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Support/AppDelegate.swift
+36-20Lines changed: 36 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -239,6 +239,40 @@ class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject {
239
239
}
240
240
}
241
241
242
+
// Resolve which info item types are actually visible in the active layout.
243
+
// The app has two rendering modes:
244
+
// - Row-based layout uses `preferences.rows` and should only allow badges for item types present in those rows.
245
+
// - Legacy layout uses `InfoItemOne...Six` and should only allow badges for slots in rows that are not hidden.
246
+
// This keeps menu bar signaling aligned with what the user can actually see in the popover.
247
+
func visibleInfoItemTypes()->Set<String>{
248
+
if !preferences.rows.isEmpty {
249
+
returnSet(
250
+
preferences.rows
251
+
.compactMap(\.items)
252
+
.flatMap{ $0.compactMap(\.type)}
253
+
)
254
+
}
255
+
256
+
varvisibleItems=[String]()
257
+
258
+
if !preferences.hideFirstRowInfoItems {
259
+
visibleItems.append(preferences.infoItemOne)
260
+
visibleItems.append(preferences.infoItemTwo)
261
+
}
262
+
263
+
if !preferences.hideSecondRowInfoItems {
264
+
visibleItems.append(preferences.infoItemThree)
265
+
visibleItems.append(preferences.infoItemFour)
266
+
}
267
+
268
+
if !preferences.hideThirdRowInfoItems {
269
+
visibleItems.append(preferences.infoItemFive)
270
+
visibleItems.append(preferences.infoItemSix)
271
+
}
272
+
273
+
returnSet(visibleItems.filter{ !$0.isEmpty })
274
+
}
275
+
242
276
// MARK: - Set and update the menu bar icon
243
277
@objcfunc setStatusBarIcon(){
244
278
@@ -358,25 +392,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject {
358
392
359
393
// Set notification counter next to the menu bar icon if enabled. https://www.hackingwithswift.com/example-code/system/how-to-insert-images-into-an-attributed-string-with-nstextattachment
360
394
361
-
// Create array with configured info items. Disabled info items should not show a notification badge in the menu bar icon
362
-
varinfoItemsEnabled:[String]=[
363
-
preferences.infoItemOne,
364
-
preferences.infoItemTwo,
365
-
preferences.infoItemThree,
366
-
preferences.infoItemFour,
367
-
preferences.infoItemFive,
368
-
preferences.infoItemSix
369
-
]
370
-
371
-
// Append all types from new structure
372
-
if !preferences.rows.isEmpty {
373
-
forrowin preferences.rows {
374
-
iflet items = row.items {
375
-
letallTypes= items.compactMap{ $0.type }
376
-
infoItemsEnabled.append(contentsOf: allTypes)
377
-
}
378
-
}
379
-
}
395
+
// Only item types visible in the currently rendered layout may drive a status bar badge.
396
+
letinfoItemsEnabled=visibleInfoItemTypes()
380
397
381
398
// Create array with extension alert booleans
382
399
varextensionAlerts:[Bool]=[]
@@ -1002,4 +1019,3 @@ class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject {
0 commit comments