Simplify UI driver storing showingUpdate state

This commit is contained in:
Zorg committed 2021-04-16 00:01:37 -07:00
1 parent 2f783e01f0
commit 6b3d2af21a
4 files changed
+18 -22

No files matched your search

+2 -5
View File
@@ -19,7 +19,6 @@
@property (nonatomic, readonly) SPUUIBasedUpdateDriver *uiDriver;
@property (nonatomic) BOOL showedUpdate;
@property (nonatomic) BOOL showingUpdate;
@end
@@ -27,7 +26,6 @@
@synthesize uiDriver = _uiDriver;
@synthesize showedUpdate = _showedUpdate;
@synthesize showingUpdate = _showingUpdate;
- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id <SPUUserDriver>)userDriver updaterDelegate:(nullable id <SPUUpdaterDelegate>)updaterDelegate
{
@@ -65,12 +63,11 @@
- (void)uiDriverDidShowUpdate
{
self.showedUpdate = YES;
self.showingUpdate = YES;
}
- (void)uiDriverFinishedShowingUpdate
- (BOOL)showingUpdate
{
self.showingUpdate = NO;
return self.uiDriver.showingUpdate;
}
- (void)basicDriverIsRequestingAbortUpdateWithError:(nullable NSError *) error
+3 -3
View File
@@ -17,11 +17,9 @@ NS_ASSUME_NONNULL_BEGIN
- (void)coreDriverIsRequestingAbortUpdateWithError:(nullable NSError *)error;
- (void)uiDriverIsRequestingAbortUpdateWithError:(nullable NSError *)error;
- (void)uiDriverDidShowUpdate;
- (void)uiDriverFinishedShowingUpdate;
@optional
- (void)uiDriverDidShowUpdate;
- (void)basicDriverDidFinishLoadingAppcast;
@end
@@ -43,6 +41,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)resumeUpdate:(id<SPUResumableUpdate>)resumableUpdate completion:(SPUUpdateDriverCompletion)completionBlock;
@property (nonatomic, readonly) BOOL showingUpdate;
- (void)abortUpdateWithError:(nullable NSError *)error;
@end
+11 -5
View File
@@ -33,6 +33,7 @@
@property (nonatomic) BOOL resumingInstallingUpdate;
@property (nonatomic) BOOL resumingDownloadedUpdate;
@property (nonatomic) BOOL preventsInstallerInteraction;
@property (nonatomic) BOOL showingUpdate;
@end
@@ -48,6 +49,7 @@
@synthesize resumingInstallingUpdate = _resumingInstallingUpdate;
@synthesize resumingDownloadedUpdate = _resumingDownloadedUpdate;
@synthesize preventsInstallerInteraction = _preventsInstallerInteraction;
@synthesize showingUpdate = _showingUpdate;
- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id <SPUUserDriver>)userDriver userInitiated:(BOOL)userInitiated updaterDelegate:(nullable id <SPUUpdaterDelegate>)updaterDelegate delegate:(id<SPUUIBasedUpdateDriverDelegate>)delegate
{
@@ -115,7 +117,7 @@
[self.userDriver showInformationalUpdateFoundWithAppcastItem:updateItem userInitiated:self.userInitiated reply:^(SPUInformationalUpdateAlertChoice choice) {
dispatch_async(dispatch_get_main_queue(), ^{
[self.delegate uiDriverFinishedShowingUpdate];
self.showingUpdate = NO;
switch (choice) {
case SPUSkipThisInformationalVersionChoice:
@@ -134,7 +136,7 @@
} else if (self.resumingDownloadedUpdate) {
[self.userDriver showDownloadedUpdateFoundWithAppcastItem:updateItem userInitiated:self.userInitiated reply:^(SPUUpdateAlertChoice choice) {
dispatch_async(dispatch_get_main_queue(), ^{
[self.delegate uiDriverFinishedShowingUpdate];
self.showingUpdate = NO;
[self.host setObject:nil forUserDefaultsKey:SUSkippedVersionKey];
switch (choice) {
@@ -158,7 +160,7 @@
} else if (!self.resumingInstallingUpdate) {
[self.userDriver showUpdateFoundWithAppcastItem:updateItem userInitiated:self.userInitiated reply:^(SPUUpdateAlertChoice choice) {
dispatch_async(dispatch_get_main_queue(), ^{
[self.delegate uiDriverFinishedShowingUpdate];
self.showingUpdate = NO;
[self.host setObject:nil forUserDefaultsKey:SUSkippedVersionKey];
switch (choice) {
@@ -181,7 +183,7 @@
} else {
[self.userDriver showResumableUpdateFoundWithAppcastItem:updateItem userInitiated:self.userInitiated reply:^(SPUInstallUpdateStatus choice) {
dispatch_async(dispatch_get_main_queue(), ^{
[self.delegate uiDriverFinishedShowingUpdate];
self.showingUpdate = NO;
[self.host setObject:nil forUserDefaultsKey:SUSkippedVersionKey];
[self.coreDriver finishInstallationWithResponse:choice displayingUserInterface:!self.preventsInstallerInteraction];
@@ -189,7 +191,11 @@
}];
}
[self.delegate uiDriverDidShowUpdate];
self.showingUpdate = YES;
if ([self.delegate respondsToSelector:@selector(uiDriverDidShowUpdate)]) {
[self.delegate uiDriverDidShowUpdate];
}
if (updateItem.releaseNotesURL != nil && (![updaterDelegate respondsToSelector:@selector(updaterShouldDownloadReleaseNotes:)] || [updaterDelegate updaterShouldDownloadReleaseNotes:self.updater])) {
NSURLRequest *request = [NSURLRequest requestWithURL:updateItem.releaseNotesURL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30];
+2 -9
View File
@@ -18,7 +18,6 @@
@property (nonatomic, readonly) SPUUIBasedUpdateDriver *uiDriver;
@property (nonatomic, readonly) id<SPUUserDriver> userDriver;
@property (nonatomic) BOOL showingUserInitiatedProgress;
@property (nonatomic) BOOL showingUpdate;
@property (nonatomic) BOOL aborted;
@end
@@ -27,7 +26,6 @@
@synthesize uiDriver = _uiDriver;
@synthesize userDriver = _userDriver;
@synthesize showingUpdate = _showingUpdate;
@synthesize showingUserInitiatedProgress = _showingUserInitiatedProgress;
@synthesize aborted = _aborted;
@@ -93,14 +91,9 @@
[self.uiDriver resumeUpdate:resumableUpdate completion:completionBlock];
}
- (void)uiDriverDidShowUpdate
- (BOOL)showingUpdate
{
self.showingUpdate = YES;
}
- (void)uiDriverFinishedShowingUpdate
{
self.showingUpdate = NO;
return self.uiDriver.showingUpdate;
}
- (void)basicDriverIsRequestingAbortUpdateWithError:(nullable NSError *)error