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

Adds standard user driver delegate method for responding to Version History button #1989

Merged
merged 6 commits into from
Oct 29, 2021
18 changes: 15 additions & 3 deletions Sparkle/SPUStandardUserDriver.m
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,21 @@ - (void)showUpdateNotFoundWithError:(NSError *)error acknowledgement:(void (^)(v
switch (reason) {
case SPUNoUpdateFoundReasonOnLatestVersion:
case SPUNoUpdateFoundReasonOnNewerThanLatestVersion: {
if (latestAppcastItem.releaseNotesURL != nil) {
// Show the user the past version history if available
[alert addButtonWithTitle:SULocalizedString(@"Version History", nil)];
// Show the user the past version history if available
NSString *localizedButtonTitle = SULocalizedString(@"Version History", nil);

// Check if the delegate implements a Version History action
id <SPUStandardUserDriverDelegate> delegate = self.delegate;

if ([delegate respondsToSelector:@selector(standardUserDriverShowVersionHistoryForAppcastItem:)]) {
[alert addButtonWithTitle:localizedButtonTitle];

secondaryAction = ^{
[delegate standardUserDriverShowVersionHistoryForAppcastItem:latestAppcastItem];
};
} else if (latestAppcastItem.releaseNotesURL != nil) {
// Fall back to opening the release notes URL (or forthcoming full version history link attr!)
[alert addButtonWithTitle:localizedButtonTitle];

secondaryAction = ^{
[[NSWorkspace sharedWorkspace] openURL:(NSURL * _Nonnull)latestAppcastItem.releaseNotesURL];
Expand Down
9 changes: 9 additions & 0 deletions Sparkle/SPUStandardUserDriverDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,13 @@ SU_EXPORT @protocol SPUStandardUserDriverDelegate <NSObject>
*/
- (_Nullable id <SUVersionDisplay>)standardUserDriverRequestsVersionDisplayer;

/**
Called if implemented when the Version History button is chosen by the user. Otherwise,
the `fullReleaseNotesLink` or `releaseNotesLink` in the appcast's latest item will be be
opened.

@param item The appcast item corresponding to the latest version available.
*/
- (void)standardUserDriverShowVersionHistoryForAppcastItem:(SUAppcastItem *_Nonnull)item;

@end