Add delegate method to hide showing version history option (#2303)

This commit is contained in:
Zorg authored and GitHub committed 2022-12-23 07:17:44 -08:00
1 parent cc90026ade
commit 91b8f4eaa0
2 files changed
+39 -21

No files matched your search

+26 -21
View File
@@ -580,31 +580,36 @@ static const NSTimeInterval SUScheduledUpdateIdleEventLeewayInterval = DEBUG ? 3
case SPUNoUpdateFoundReasonOnLatestVersion:
case SPUNoUpdateFoundReasonOnNewerThanLatestVersion: {
// Show the user the past version history if available
NSString *localizedButtonTitle = SULocalizedString(@"Version History", nil);
// Check if the delegate implements a Version History action
// Check if the delegate allows showing the Version History
id <SPUStandardUserDriverDelegate> delegate = self.delegate;
BOOL shouldShowVersionHistory = (![delegate respondsToSelector:@selector(standardUserDriverShouldShowVersionHistoryForAppcastItem:)] || [delegate standardUserDriverShouldShowVersionHistoryForAppcastItem:latestAppcastItem]);
if ([delegate respondsToSelector:@selector(standardUserDriverShowVersionHistoryForAppcastItem:)]) {
[alert addButtonWithTitle:localizedButtonTitle];
if (shouldShowVersionHistory) {
NSString *localizedButtonTitle = SULocalizedString(@"Version History", nil);
secondaryAction = ^{
[delegate standardUserDriverShowVersionHistoryForAppcastItem:latestAppcastItem];
};
} else if (latestAppcastItem.fullReleaseNotesURL != nil) {
// Open the full release notes URL if informed
[alert addButtonWithTitle:localizedButtonTitle];
secondaryAction = ^{
[[NSWorkspace sharedWorkspace] openURL:(NSURL * _Nonnull)latestAppcastItem.fullReleaseNotesURL];
};
} else if (latestAppcastItem.releaseNotesURL != nil) {
// Fall back to opening the release notes URL
[alert addButtonWithTitle:localizedButtonTitle];
secondaryAction = ^{
[[NSWorkspace sharedWorkspace] openURL:(NSURL * _Nonnull)latestAppcastItem.releaseNotesURL];
};
// Check if the delegate implements its own Version History action
if ([delegate respondsToSelector:@selector(standardUserDriverShowVersionHistoryForAppcastItem:)]) {
[alert addButtonWithTitle:localizedButtonTitle];
secondaryAction = ^{
[delegate standardUserDriverShowVersionHistoryForAppcastItem:latestAppcastItem];
};
} else if (latestAppcastItem.fullReleaseNotesURL != nil) {
// Open the full release notes URL if informed
[alert addButtonWithTitle:localizedButtonTitle];
secondaryAction = ^{
[[NSWorkspace sharedWorkspace] openURL:(NSURL * _Nonnull)latestAppcastItem.fullReleaseNotesURL];
};
} else if (latestAppcastItem.releaseNotesURL != nil) {
// Fall back to opening the release notes URL
[alert addButtonWithTitle:localizedButtonTitle];
secondaryAction = ^{
[[NSWorkspace sharedWorkspace] openURL:(NSURL * _Nonnull)latestAppcastItem.releaseNotesURL];
};
}
}
break;
+13
View File
@@ -42,6 +42,19 @@ SU_EXPORT @protocol SPUStandardUserDriverDelegate <NSObject>
*/
- (_Nullable id <SUVersionDisplay>)standardUserDriverRequestsVersionDisplayer;
/**
Decides whether or not the standard user driver should provide an option to show full release notes to the user.
When a user checks for new updates and no new update is found, Sparkle by default will offer to show the application's version history to the user
by providing a "Version History" button in the no new update available alert.
If this delegate method is implemented to return `NO`, then Sparkle will not provide an option to show full release notes to the user.
@param item The appcast item corresponding to the latest version available.
@return @c YES to allow Sparkle to show full release notes to the user, otherwise @c NO to disallow this.
*/
- (BOOL)standardUserDriverShouldShowVersionHistoryForAppcastItem:(SUAppcastItem *)item;
/**
Handles showing the full release notes to the user.