mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-24 04:38:16 +00:00
Add delegate method to hide showing version history option (#2303)
This commit is contained in:
2 files changed
+39
-21
No files matched your search
Vendored
+26
-21
@@ -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
@@ -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.
|
||||
|
||||
|
||||
Reference in new issue
Block a user