Remove critical and major upgrade properties from SPUUpdateState

This commit is contained in:
Zorg committed 2021-05-31 10:22:55 -07:00
1 parent 8fb44df0b7
commit f51bb996e6
8 files changed
+16 -26

No files matched your search

+1 -1
View File
@@ -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;
+2 -2
View File
@@ -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);
+2 -5
View File
@@ -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];
+1 -1
View File
@@ -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
-2
View File
@@ -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
+5 -10
View File
@@ -17,21 +17,20 @@
#define SPUUserUpdateStateMajorUpgradeKey @"SPUUserUpdateStateMajorUpgrade"
#define SPUUserUpdateStateCriticalUpdateKey @"SPUUserUpdateStateCriticalUpdate"
@interface SPUUpdateState () <NSSecureCoding>
@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
+1 -1
View File
@@ -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]);
+4 -4
View File
@@ -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 {