MacGui: show the notifications in foreground only if there is a sound

This commit is contained in:
Damiano Galassi 2025-10-20 17:12:31 +02:00
parent 8bb31a753d
commit e1c859f404
No known key found for this signature in database
GPG Key ID: 5452E231DFDBCA11
3 changed files with 3 additions and 13 deletions

View File

@ -28,8 +28,6 @@ extern NSString * const HBQueueDidStartNotification;
extern NSString * const HBQueueDidCompleteNotification;
extern NSString * const HBQueueDidChangeStateNotification;
extern NSString * const HBQueueNotificationCanceledKey; // NSNumber
extern NSString * const HBQueueDidStartItemNotification;
extern NSString * const HBQueueDidCompleteItemNotification;
extern NSString * const HBQueueItemNotificationItemKey; // HBQueueJobItem

View File

@ -33,8 +33,6 @@ NSString * const HBQueueLowSpaceAlertNotification = @"HBQueueLowSpaceAlertNotifi
NSString * const HBQueueDidStartNotification = @"HBQueueDidStartNotification";
NSString * const HBQueueDidCompleteNotification = @"HBQueueDidCompleteNotification";
NSString * const HBQueueNotificationCanceledKey = @"HBQueueNotificationCanceledKey";
NSString * const HBQueueDidStartItemNotification = @"HBQueueDidStartItemNotification";
NSString * const HBQueueDidCompleteItemNotification = @"HBQueueDidCompleteItemNotification";
NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemKey";
@ -801,9 +799,7 @@ static void powerSourceCallback(void *context)
NSUInteger index = [self.itemsInternal indexOfObject:nextItem];
[self removeItemsAtIndexes:[NSIndexSet indexSetWithIndex:index]];
[self allowSleep];
[NSNotificationCenter.defaultCenter postNotificationName:HBQueueDidCompleteNotification
object:self
userInfo:@{HBQueueNotificationCanceledKey : @YES}];
[NSNotificationCenter.defaultCenter postNotificationName:HBQueueDidCompleteNotification object:self];
}
}
else

View File

@ -86,11 +86,7 @@
}];
[NSNotificationCenter.defaultCenter addObserverForName:HBQueueDidCompleteNotification object:_queue queue:NSOperationQueue.mainQueue usingBlock:^(NSNotification * _Nonnull note) {
BOOL canceled = [note.userInfo[HBQueueNotificationCanceledKey] boolValue];
if (canceled == NO)
{
[self queueCompletedAlerts];
}
[self queueCompletedAlerts];
}];
[NSNotificationCenter.defaultCenter addObserverForName:HBQueueDidCompleteItemNotification object:_queue queue:NSOperationQueue.mainQueue usingBlock:^(NSNotification * _Nonnull note) {
@ -436,7 +432,7 @@ NSString * const HBQueueItemNotificationShowCategory = @"HBQueueItemNotification
willPresentNotification:(UNNotification *)notification
withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler API_AVAILABLE(macos(10.15))
{
completionHandler(UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionSound);
completionHandler(UNNotificationPresentationOptionSound);
}
- (void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification