Merge pull request #1803 from sparkle-project/preventAccidentalInstalls-2.x

Disable keyboard shortcut for active not-initiated scheduled checks
This commit is contained in:
Mayur Pawashe authored and GitHub committed 2021-03-23 19:22:32 -07:00
commit 25001d83ee
1 file changed
+17 -13
+17 -13
View File
@@ -76,7 +76,7 @@
#pragma mark Update Alert Focus
- (void)setUpFocusForActiveUpdateAlert
- (void)setUpFocusForActiveUpdateAlertWithUserInitiation:(BOOL)userInitiated
{
// Make sure the window is loaded in any case
[self.activeUpdateAlert window];
@@ -89,10 +89,14 @@
}
// Only show the update alert if the app is active; otherwise, we'll wait until it is.
if ([NSApp isActive])
if ([NSApp isActive]) {
if (!userInitiated) {
[self.activeUpdateAlert disableKeyboardShortcutForInstallButton];
}
[self.activeUpdateAlert.window makeKeyAndOrderFront:self];
else
} else {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:NSApplicationDidBecomeActiveNotification object:NSApp];
}
}
- (void)applicationDidBecomeActive:(NSNotification *)__unused aNotification
@@ -103,7 +107,7 @@
#pragma mark Update Found
- (void)showUpdateFoundWithAlertHandler:(SUUpdateAlert *(^)(SPUStandardUserDriver *, SUHost *, id<SUVersionDisplay>))alertHandler
- (void)showUpdateFoundWithAlertHandler:(SUUpdateAlert *(^)(SPUStandardUserDriver *, SUHost *, id<SUVersionDisplay>))alertHandler userInitiated:(BOOL)userInitiated
{
id <SUVersionDisplay> versionDisplayer = nil;
if ([self.delegate respondsToSelector:@selector(standardUserDriverRequestsVersionDisplayer)]) {
@@ -114,10 +118,10 @@
SUHost *host = self.host;
self.activeUpdateAlert = alertHandler(weakSelf, host, versionDisplayer);
[self setUpFocusForActiveUpdateAlert];
[self setUpFocusForActiveUpdateAlertWithUserInitiation:userInitiated];
}
- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)__unused userInitiated reply:(void (^)(SPUUpdateAlertChoice))reply
- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated reply:(void (^)(SPUUpdateAlertChoice))reply
{
assert(NSThread.isMainThread);
@@ -126,10 +130,10 @@
reply(choice);
weakSelf.activeUpdateAlert = nil;
}];
}];
} userInitiated:userInitiated];
}
- (void)showDownloadedUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)__unused userInitiated reply:(void (^)(SPUUpdateAlertChoice))reply
- (void)showDownloadedUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated reply:(void (^)(SPUUpdateAlertChoice))reply
{
assert(NSThread.isMainThread);
@@ -138,10 +142,10 @@
reply(choice);
weakSelf.activeUpdateAlert = nil;
}];
}];
} userInitiated:userInitiated];
}
- (void)showResumableUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)__unused userInitiated reply:(void (^)(SPUInstallUpdateStatus))reply
- (void)showResumableUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated reply:(void (^)(SPUInstallUpdateStatus))reply
{
assert(NSThread.isMainThread);
@@ -150,10 +154,10 @@
reply(choice);
weakSelf.activeUpdateAlert = nil;
}];
}];
} userInitiated:userInitiated];
}
- (void)showInformationalUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)__unused userInitiated reply:(void (^)(SPUInformationalUpdateAlertChoice))reply
- (void)showInformationalUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated reply:(void (^)(SPUInformationalUpdateAlertChoice))reply
{
assert(NSThread.isMainThread);
@@ -162,7 +166,7 @@
reply(choice);
weakSelf.activeUpdateAlert = nil;
}];
}];
} userInitiated:userInitiated];
}
- (void)showUpdateReleaseNotesWithDownloadData:(SPUDownloadData *)downloadData