@@ -36,8 +36,8 @@ class NotificationService {
36
36
37
37
func sendNotification(
38
38
message: String ,
39
- buttonText: String ,
40
- command: String ,
39
+ buttonText: String ? = nil ,
40
+ command: String ? = nil ,
41
41
notificationType: NotificationType
42
42
) {
43
43
guard appState. preferences. notificationInterval > 0 else {
@@ -47,10 +47,12 @@ class NotificationService {
47
47
48
48
let imagePath = appState. preferences. notificationImage. isEmpty ? nil : appState. preferences. notificationImage
49
49
50
- if let lastDate = AppStorageHelper . shared. getLastNotificationDate ( for: notificationType) ,
51
- Date ( ) . timeIntervalSince ( lastDate) < TimeInterval ( appState. preferences. notificationInterval * 3600 ) {
52
- Logger . shared. logDebug ( " Notification interval for \( notificationType) not reached, skipping notification " )
53
- return
50
+ if notificationType != . generic {
51
+ if let lastDate = AppStorageHelper . shared. getLastNotificationDate ( for: notificationType) ,
52
+ Date ( ) . timeIntervalSince ( lastDate) < TimeInterval ( appState. preferences. notificationInterval * 3600 ) {
53
+ Logger . shared. logDebug ( " Notification interval for \( notificationType) not reached, skipping notification " )
54
+ return
55
+ }
54
56
}
55
57
56
58
let content = UNMutableNotificationContent ( )
@@ -68,15 +70,20 @@ class NotificationService {
68
70
Logger . shared. logError ( " Failed to attach image: \( error. localizedDescription) " )
69
71
}
70
72
}
71
- // Define the notification category and actions
72
- let action = UNNotificationAction (
73
- identifier: " RUN_COMMAND " ,
74
- title: buttonText,
75
- options: [ . foreground]
76
- )
73
+
74
+ var actions : [ UNNotificationAction ] = [ ]
75
+ if let buttonText = buttonText, let command = command {
76
+ let action = UNNotificationAction (
77
+ identifier: " RUN_COMMAND " ,
78
+ title: buttonText,
79
+ options: [ . foreground]
80
+ )
81
+ actions. append ( action)
82
+ }
83
+
77
84
let category = UNNotificationCategory (
78
85
identifier: " ACTIONABLE " ,
79
- actions: [ action ] ,
86
+ actions: actions ,
80
87
intentIdentifiers: [ ]
81
88
)
82
89
UNUserNotificationCenter . current ( ) . setNotificationCategories ( [ category] )
@@ -137,7 +144,6 @@ class BadgeManager {
137
144
private func updateBadge( ) {
138
145
DispatchQueue . main. async {
139
146
if self . badgeCount > 0 {
140
- print ( " Setting badge count to \( self . badgeCount) " )
141
147
NSApplication . shared. dockTile. showsApplicationBadge = true
142
148
NSApplication . shared. dockTile. badgeLabel = nil
143
149
NSApplication . shared. dockTile. badgeLabel = String ( self . badgeCount)
0 commit comments