From d75856cfeeda51bfcef6f9f6dcdafe7c921e7713 Mon Sep 17 00:00:00 2001 From: Daniel Jalkut Date: Mon, 27 Jul 2015 15:13:07 -0400 Subject: [PATCH] Declare informationOnlyUpdate as a property of SUAppcastItem. Declaring a property makes it obvious where changes to the logic about whether an update is "information only" should be made, and leaves the code at the calling point more readable. Instead of inferring that an appast item is information only by the simple omission of a fileURL, require that it also have a infoURL. --- Sparkle/SUAppcastItem.h | 1 + Sparkle/SUAppcastItem.m | 5 +++++ Sparkle/SUUpdateAlert.m | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Sparkle/SUAppcastItem.h b/Sparkle/SUAppcastItem.h index e4c2a06d..86843bfb 100644 --- a/Sparkle/SUAppcastItem.h +++ b/Sparkle/SUAppcastItem.h @@ -32,6 +32,7 @@ SU_EXPORT @interface SUAppcastItem : NSObject @property (getter=isDeltaUpdate, readonly) BOOL deltaUpdate; @property (getter=isCriticalUpdate, readonly) BOOL criticalUpdate; +@property (getter=isInformationOnlyUpdate, readonly) BOOL informationOnlyUpdate; // Returns the dictionary provided in initWithDictionary; this might be useful later for extensions. @property (readonly, copy) NSDictionary *propertiesDictionary; diff --git a/Sparkle/SUAppcastItem.m b/Sparkle/SUAppcastItem.m index 2a11f247..67eeee07 100644 --- a/Sparkle/SUAppcastItem.m +++ b/Sparkle/SUAppcastItem.m @@ -55,6 +55,11 @@ return [self.propertiesDictionary[SUAppcastElementTags] containsObject:SUAppcastElementCriticalUpdate]; } +- (BOOL)isInformationOnlyUpdate +{ + return (([self infoURL] != nil) && ([self fileURL] == nil)); +} + - (instancetype)initWithDictionary:(NSDictionary *)dict { return [self initWithDictionary:dict failureReason:nil]; diff --git a/Sparkle/SUUpdateAlert.m b/Sparkle/SUUpdateAlert.m index 6338956d..a386c716 100644 --- a/Sparkle/SUUpdateAlert.m +++ b/Sparkle/SUUpdateAlert.m @@ -186,7 +186,7 @@ [self.window setLevel:NSFloatingWindowLevel]; // This means the window will float over all other apps, if our app is switched out ?! } - if ([self.updateItem fileURL] == nil) { + if (self.updateItem.isInformationOnlyUpdate) { [self.installButton setTitle:SULocalizedString(@"Learn More...", @"Alternate title for 'Install Update' button when there's no download in RSS feed.")]; [self.installButton setAction:@selector(openInfoURL:)]; }