Don't check for updates if Do Not Disturb is on

This commit is contained in:
Kornel committed 2018-04-24 04:20:51 +01:00
1 parent 0d03b4006d
commit d5a1ba44ff
1 file changed
+16 -1
+16 -1
View File
@@ -299,8 +299,23 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
- (void)checkForUpdatesInBackground
{
BOOL automatic = [self automaticallyDownloadsUpdates];
if (!automatic) {
if (@available(macOS 10.9, *)) {
NSUserDefaults *defaults = [[NSUserDefaults alloc] initWithSuiteName:@"com.apple.notificationcenterui"];
BOOL dnd = [defaults boolForKey:@"doNotDisturb"];
if (dnd) {
SULog(SULogLevelDefault, @"Delayed update, because Do Not Disturb is on");
[self updateLastUpdateCheckDate];
[self scheduleNextUpdateCheck];
return;
}
}
}
// Do not use reachability for a preflight check. This can be deceptive and a bad idea. Apple does not recommend doing it.
SUUpdateDriver *theUpdateDriver = [[([self automaticallyDownloadsUpdates] ? [SUAutomaticUpdateDriver class] : [SUScheduledUpdateDriver class])alloc] initWithUpdater:self];
SUUpdateDriver *theUpdateDriver = [[(automatic ? [SUAutomaticUpdateDriver class] : [SUScheduledUpdateDriver class])alloc] initWithUpdater:self];
[self checkForUpdatesWithDriver:theUpdateDriver];
}