mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-27 05:04:27 +00:00
Tell user if they are running newer version than latest appcast item
This ports https://github.com/sparkle-project/Sparkle/pull/1427 to 2.x
This commit is contained in:
1 parent
a9254d1e02
commit
6b0d9f0de2
3 files changed
+27
-5
No files matched your search
Vendored
+24
-3
@@ -156,7 +156,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)didNotFindUpdate
|
||||
- (void)didNotFindUpdateWithLatestAppcastItem:(nullable SUAppcastItem *)latestAppcastItem hostToLatestAppcastItemComparisonResult:(NSComparisonResult)hostToLatestAppcastItemComparisonResult
|
||||
{
|
||||
if (!self.aborted) {
|
||||
if ([self.updaterDelegate respondsToSelector:@selector((updaterDidNotFindUpdate:))]) {
|
||||
@@ -164,13 +164,34 @@
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:self.updater];
|
||||
|
||||
NSString *localizedDescription;
|
||||
NSString *recoverySuggestion;
|
||||
NSString *recoveryOption;
|
||||
|
||||
if (latestAppcastItem != nil) { // if the appcast was successfully loaded
|
||||
localizedDescription = SULocalizedString(@"You're up-to-date!", "Status message shown when the user checks for updates but is already current or the feed doesn't contain any updates.");
|
||||
|
||||
if (hostToLatestAppcastItemComparisonResult == NSOrderedDescending) { // this means the user is a 'newer than latest' version. give a slight hint to the user instead of wrongly claiming this version is identical to the latest feed version.
|
||||
recoverySuggestion = [NSString stringWithFormat:SULocalizedString(@"%@ %@ is currently the newest version available.\n(You are currently running version %@.)", nil), [self.host name], latestAppcastItem.displayVersionString, [self.host displayVersion]];
|
||||
} else {
|
||||
recoverySuggestion = [NSString stringWithFormat:SULocalizedString(@"%@ %@ is currently the newest version available.", nil), [self.host name], [self.host displayVersion]];
|
||||
}
|
||||
|
||||
recoveryOption = @"OK";
|
||||
} else {
|
||||
localizedDescription = SULocalizedString(@"Update Error!", nil);
|
||||
recoverySuggestion = SULocalizedString(@"No valid update information could be loaded.", nil);
|
||||
recoveryOption = @"Cancel Update";
|
||||
}
|
||||
|
||||
NSError *notFoundError =
|
||||
[NSError
|
||||
errorWithDomain:SUSparkleErrorDomain
|
||||
code:SUNoUpdateError
|
||||
userInfo:@{
|
||||
NSLocalizedDescriptionKey: SULocalizedString(@"You're up-to-date!", "Status message shown when the user checks for updates but is already current or the feed doesn't contain any updates."),
|
||||
NSLocalizedRecoverySuggestionErrorKey: [NSString stringWithFormat:SULocalizedString(@"%@ %@ is currently the newest version available.", nil), [self.host name], [self.host displayVersion]]
|
||||
NSLocalizedDescriptionKey: localizedDescription,
|
||||
NSLocalizedRecoverySuggestionErrorKey: recoverySuggestion,
|
||||
NSLocalizedRecoveryOptionsErrorKey: @[recoveryOption]
|
||||
}
|
||||
];
|
||||
[self.delegate basicDriverIsRequestingAbortUpdateWithError:notFoundError];
|
||||
|
||||
Vendored
+1
-1
@@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (void)didFailToFetchAppcastWithError:(NSError *)error;
|
||||
- (void)didFinishLoadingAppcast:(SUAppcast *)appcast;
|
||||
- (void)didFindValidUpdateWithAppcastItem:(SUAppcastItem *)appcastItem preventsAutoupdate:(BOOL)preventsAutoupdate;
|
||||
- (void)didNotFindUpdate;
|
||||
- (void)didNotFindUpdateWithLatestAppcastItem:(nullable SUAppcastItem *)latestAppcastItem hostToLatestAppcastItemComparisonResult:(NSComparisonResult)hostToLatestAppcastItemComparisonResult;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Vendored
+2
-1
@@ -110,7 +110,8 @@
|
||||
self.nonDeltaUpdateItem = nonDeltaUpdateItem;
|
||||
[self.delegate didFindValidUpdateWithAppcastItem:item preventsAutoupdate:[self itemPreventsAutoupdate:item]];
|
||||
} else {
|
||||
[self.delegate didNotFindUpdate];
|
||||
NSComparisonResult hostToLatestAppcastItemComparisonResult = (item != nil) ? [[self versionComparator] compareVersion:[self.host version] toVersion:[item versionString]] : 0;
|
||||
[self.delegate didNotFindUpdateWithLatestAppcastItem:item hostToLatestAppcastItemComparisonResult:hostToLatestAppcastItemComparisonResult];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user