From 4ebde0d584aeace1d54520baf757b433d1479885 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Sun, 3 Jun 2018 18:39:07 -0700 Subject: [PATCH] No longer send '(null)' notifications for files missing artist and/or album tags. --- Application/PlaybackEventController.m | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Application/PlaybackEventController.m b/Application/PlaybackEventController.m index e12a09546..d9dc69eb6 100644 --- a/Application/PlaybackEventController.m +++ b/Application/PlaybackEventController.m @@ -122,12 +122,23 @@ typedef enum NSUserNotification *notif = [[NSUserNotification alloc] init]; notif.title = [pe title]; + NSString *subtitle; + if ([pe artist] && [pe album]) { + subtitle = [NSString stringWithFormat:@"%@ - %@", [pe artist], [pe album]]; + } else if ([pe artist]) { + subtitle = [pe artist]; + } else if ([pe album]) { + subtitle = [pe album]; + } else { + subtitle = @""; + } + if ([defaults boolForKey:@"notifications.itunes-style"]) { - notif.subtitle = [NSString stringWithFormat:@"%@ - %@", [pe artist], [pe album]]; + notif.subtitle = subtitle; [notif setValue:@YES forKey:@"_showsButtons"]; } else { - notif.informativeText = [NSString stringWithFormat:@"%@ - %@", [pe artist], [pe album]]; + notif.informativeText = subtitle; } if ([notif respondsToSelector:@selector(setContentImage:)]) {