diff --git a/Sparkle/SPUSkippedUpdate.h b/Sparkle/SPUSkippedUpdate.h index 40259373..ebf44aad 100644 --- a/Sparkle/SPUSkippedUpdate.h +++ b/Sparkle/SPUSkippedUpdate.h @@ -24,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN + (void)clearSkippedUpdateForHost:(SUHost *)host; -+ (void)skipUpdate:(SUAppcastItem *)updateItem host:(SUHost *)host majorUpgrade:(BOOL)majorUpgrade; ++ (void)skipUpdate:(SUAppcastItem *)updateItem host:(SUHost *)host; // At least one of minorVersion or majorVersion should be non-nil - (instancetype)initWithMinorVersion:(nullable NSString *)minorVersion majorVersion:(nullable NSString *)majorVersion; diff --git a/Sparkle/SPUSkippedUpdate.m b/Sparkle/SPUSkippedUpdate.m index e8791413..c3d61bed 100644 --- a/Sparkle/SPUSkippedUpdate.m +++ b/Sparkle/SPUSkippedUpdate.m @@ -49,9 +49,9 @@ [host setObject:nil forUserDefaultsKey:SUSkippedMajorVersionKey]; } -+ (void)skipUpdate:(SUAppcastItem *)updateItem host:(SUHost *)host majorUpgrade:(BOOL)majorUpgrade ++ (void)skipUpdate:(SUAppcastItem *)updateItem host:(SUHost *)host { - if (majorUpgrade) { + if (updateItem.majorUpgrade) { NSString *majorVersion = updateItem.minimumAutoupdateVersion; assert(majorVersion != nil); diff --git a/Sparkle/SPUUIBasedUpdateDriver.m b/Sparkle/SPUUIBasedUpdateDriver.m index fbd1c538..4dd0bcfc 100644 --- a/Sparkle/SPUUIBasedUpdateDriver.m +++ b/Sparkle/SPUUIBasedUpdateDriver.m @@ -180,10 +180,7 @@ stage = SPUUpdateStageNotDownloaded; } - BOOL majorUpgrade = preventsAutoupdate; - BOOL criticalUpdate = updateItem.isCriticalUpdate; - - SPUUpdateState *state = [[SPUUpdateState alloc] initWithStage:stage userInitiated:self.userInitiated majorUpgrade:majorUpgrade criticalUpdate:criticalUpdate]; + SPUUpdateState *state = [[SPUUpdateState alloc] initWithStage:stage userInitiated:self.userInitiated]; [self.userDriver showUpdateFoundWithAppcastItem:updateItem state:state reply:^(SPUUserUpdateChoice userChoice) { dispatch_async(dispatch_get_main_queue(), ^{ @@ -215,7 +212,7 @@ break; } case SPUUserUpdateChoiceSkip: { - [SPUSkippedUpdate skipUpdate:updateItem host:self.host majorUpgrade:majorUpgrade]; + [SPUSkippedUpdate skipUpdate:updateItem host:self.host]; if ([self.updaterDelegate respondsToSelector:@selector(updater:userDidSkipThisVersion:)]) { [self.updaterDelegate updater:self.updater userDidSkipThisVersion:updateItem]; diff --git a/Sparkle/SPUUpdateState+Private.h b/Sparkle/SPUUpdateState+Private.h index ed040132..1c2ab7e8 100644 --- a/Sparkle/SPUUpdateState+Private.h +++ b/Sparkle/SPUUpdateState+Private.h @@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN @interface SPUUpdateState (Private) -- (instancetype)initWithStage:(SPUUpdateStage)stage userInitiated:(BOOL)userInitiated majorUpgrade:(BOOL)majorUpgrade criticalUpdate:(BOOL)criticalUpdate; +- (instancetype)initWithStage:(SPUUpdateStage)stage userInitiated:(BOOL)userInitiated; @end diff --git a/Sparkle/SPUUpdateState.h b/Sparkle/SPUUpdateState.h index fd16f377..60f8826e 100644 --- a/Sparkle/SPUUpdateState.h +++ b/Sparkle/SPUUpdateState.h @@ -33,8 +33,6 @@ SU_EXPORT @interface SPUUpdateState : NSObject @property (nonatomic, readonly) SPUUpdateStage stage; @property (nonatomic, readonly) BOOL userInitiated; -@property (nonatomic, readonly) BOOL majorUpgrade; -@property (nonatomic, readonly) BOOL criticalUpdate; @end diff --git a/Sparkle/SPUUpdateState.m b/Sparkle/SPUUpdateState.m index a86a8d4e..19e5c400 100644 --- a/Sparkle/SPUUpdateState.m +++ b/Sparkle/SPUUpdateState.m @@ -17,21 +17,20 @@ #define SPUUserUpdateStateMajorUpgradeKey @"SPUUserUpdateStateMajorUpgrade" #define SPUUserUpdateStateCriticalUpdateKey @"SPUUserUpdateStateCriticalUpdate" +@interface SPUUpdateState () +@end + @implementation SPUUpdateState @synthesize stage = _stage; @synthesize userInitiated = _userInitiated; -@synthesize majorUpgrade = _majorUpgrade; -@synthesize criticalUpdate = _criticalUpdate; -- (instancetype)initWithStage:(SPUUpdateStage)stage userInitiated:(BOOL)userInitiated majorUpgrade:(BOOL)majorUpgrade criticalUpdate:(BOOL)criticalUpdate +- (instancetype)initWithStage:(SPUUpdateStage)stage userInitiated:(BOOL)userInitiated { self = [super init]; if (self != nil) { _stage = stage; _userInitiated = userInitiated; - _majorUpgrade = majorUpgrade; - _criticalUpdate = criticalUpdate; } return self; } @@ -40,18 +39,14 @@ { [encoder encodeInteger:self.stage forKey:SPUUserUpdateStateStageKey]; [encoder encodeBool:self.userInitiated forKey:SPUUserUpdateStateUserInitiatedKey]; - [encoder encodeBool:self.majorUpgrade forKey:SPUUserUpdateStateMajorUpgradeKey]; - [encoder encodeBool:self.criticalUpdate forKey:SPUUserUpdateStateCriticalUpdateKey]; } - (instancetype)initWithCoder:(NSCoder *)decoder { SPUUpdateStage stage = [decoder decodeIntegerForKey:SPUUserUpdateStateStageKey]; BOOL userInitiated = [decoder decodeBoolForKey:SPUUserUpdateStateUserInitiatedKey]; - BOOL majorUpgrade = [decoder decodeBoolForKey:SPUUserUpdateStateMajorUpgradeKey]; - BOOL criticalUpdate = [decoder decodeBoolForKey:SPUUserUpdateStateCriticalUpdateKey]; - return [self initWithStage:stage userInitiated:userInitiated majorUpgrade:majorUpgrade criticalUpdate:criticalUpdate]; + return [self initWithStage:stage userInitiated:userInitiated]; } + (BOOL)supportsSecureCoding diff --git a/Sparkle/SUAppcastDriver.m b/Sparkle/SUAppcastDriver.m index 816b7337..1ea31a7c 100644 --- a/Sparkle/SUAppcastDriver.m +++ b/Sparkle/SUAppcastDriver.m @@ -242,7 +242,7 @@ BOOL passesPhasedRollout = [self itemIsReadyForPhasedRollout:item phasedUpdateGroup:phasedUpdateGroup currentDate:currentDate hostVersion:hostVersion versionComparator:versionComparator]; - BOOL passesMinimumAutoupdateVersion = (!testMinimumAutoupdateVersion || !item.state.majorUpgrade); + BOOL passesMinimumAutoupdateVersion = (!testMinimumAutoupdateVersion || !item.majorUpgrade); BOOL passesSkippedUpdates = (versionComparator == nil || hostVersion == nil || ![self item:item containsSkippedUpdate:skippedUpdate hostPassesSkippedMajorVersion:hostPassesSkippedMajorVersion versionComparator:versionComparator]); diff --git a/Sparkle/SUUpdateAlert.m b/Sparkle/SUUpdateAlert.m index bd105384..cb830306 100644 --- a/Sparkle/SUUpdateAlert.m +++ b/Sparkle/SUUpdateAlert.m @@ -139,7 +139,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE - (IBAction)skipThisVersion:(id)__unused sender { - if (self.state.majorUpgrade) { + if (self.updateItem.majorUpgrade) { NSAlert *alert = [[NSAlert alloc] init]; alert.alertStyle = NSAlertStyleInformational; alert.informativeText = SULocalizedString(@"Skipping this major upgrade will opt out of alerts for future updates.", nil); @@ -381,7 +381,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE self.laterButton.title = SULocalizedString(@"Install on Quit", @"Alternate title for 'Remind Me Later' button when downloaded updates can be resumed"); } - if (self.state.criticalUpdate && !self.state.majorUpgrade) { + if (self.updateItem.criticalUpdate && !self.updateItem.majorUpgrade) { self.skipButton.hidden = YES; self.laterButton.hidden = YES; } @@ -407,7 +407,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE - (NSString *)titleText { - if (self.state.criticalUpdate) + if (self.updateItem.criticalUpdate) { return [NSString stringWithFormat:SULocalizedString(@"An important update to %@ is ready to install", nil), [self.host name]]; } @@ -438,7 +438,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE if (self.state.stage == SPUUpdateStageInformational) { finalString = [NSString stringWithFormat:SULocalizedString(@"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?", @"Description text for SUUpdateAlert when the update informational with no download."), self.host.name, updateItemVersion, hostVersion]; - } else if (self.state.criticalUpdate) { + } else if (self.updateItem.criticalUpdate) { if (self.state.stage == SPUUpdateStageNotDownloaded) { finalString = [NSString stringWithFormat:SULocalizedString(@"%@ %@ is now available--you have %@. This is an important update; would you like to download it now?", @"Description text for SUUpdateAlert when the critical update is downloadable."), self.host.name, updateItemVersion, hostVersion]; } else {