Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call update permission prompt delegate method only when needed #2622

Merged
merged 3 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions Sparkle/SPUUpdater.m
Original file line number Diff line number Diff line change
Expand Up @@ -382,19 +382,18 @@ - (void)startUpdateCycle SPU_OBJC_DIRECT

id<SPUUpdaterDelegate> delegate = _delegate;

// If the user has been asked about automatic checks, don't bother prompting
// If the user has been asked about automatic checks or the developer has overridden the setting, don't bother prompting
// When the user answers to the permission prompt, this will be set to either @YES or @NO instead of nil
if ([_host objectForUserDefaultsKey:SUEnableAutomaticChecksKey] != nil) {
if ([_host objectForKey:SUEnableAutomaticChecksKey] != nil) {
shouldPrompt = NO;
}
// Does the delegate want to take care of the logic for when we should ask permission to update?
else if ([delegate respondsToSelector:@selector((updaterShouldPromptForPermissionToCheckForUpdates:))]) {
shouldPrompt = [delegate updaterShouldPromptForPermissionToCheckForUpdates:self];
}
// Has the user been asked already? And don't ask if the host has a default value set in its Info.plist.
else if ([_host objectForKey:SUEnableAutomaticChecksKey] == nil) {
else {
// We wait until the second launch of the updater for this host bundle, unless explicitly overridden via SUPromptUserOnFirstLaunchKey.
shouldPrompt = [_host objectForKey:SUPromptUserOnFirstLaunchKey] || hasLaunchedBefore;
shouldPrompt = hasLaunchedBefore || [_host boolForInfoDictionaryKey:SUPromptUserOnFirstLaunchKey];
}

if (!hasLaunchedBefore) {
Expand Down
6 changes: 5 additions & 1 deletion Sparkle/SPUUpdaterDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ SU_EXPORT extern NSString *const SUSystemProfilerPreferredLanguageKey;
/**
Returns whether Sparkle should prompt the user about checking for new updates automatically.

Use this to override the default behavior.
Use this to override the default behavior, which is to prompt for permission to check for updates on second app launch
(if SUEnableAutomaticChecks is not specified).

This method is not called if SUEnableAutomaticChecks is defined in Info.plist or
if the user has responded to a permission prompt before.

@param updater The updater instance.
@return @c YES if the updater should prompt for permission to check for new updates automatically, otherwise @c NO
Expand Down
2 changes: 1 addition & 1 deletion Sparkle/SUUpdater.m
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ - (NSString *)feedURLStringForUpdater:(SPUUpdater *)__unused updater
- (BOOL)updaterShouldPromptForPermissionToCheckForUpdates:(SPUUpdater *)__unused updater
{
BOOL shouldPrompt = YES;
if ([_delegate respondsToSelector:@selector(updater:didFinishLoadingAppcast:)]) {
if ([_delegate respondsToSelector:@selector(updaterShouldPromptForPermissionToCheckForUpdates:)]) {
shouldPrompt = [_delegate updaterShouldPromptForPermissionToCheckForUpdates:self];
}
return shouldPrompt;
Expand Down
Loading