From 6de75413e85c45183f9cf9c641aefa74e3421c0e Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 27 Mar 2016 16:36:24 -0400 Subject: [PATCH] Don't show user initiated progress when resuming an update Retrieving the data to resume an update happens very quickly. --- Sparkle/SUUserInitiatedUpdateDriver.m | 30 ++++++++++++++------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/Sparkle/SUUserInitiatedUpdateDriver.m b/Sparkle/SUUserInitiatedUpdateDriver.m index 637895a5..224a0250 100644 --- a/Sparkle/SUUserInitiatedUpdateDriver.m +++ b/Sparkle/SUUserInitiatedUpdateDriver.m @@ -18,6 +18,7 @@ @property (nonatomic, readonly) SUUIBasedUpdateDriver *uiDriver; @property (nonatomic, readonly) id userDriver; +@property (nonatomic) BOOL showingUserInitiatedProgress; @property (nonatomic) BOOL canceledCheckForUpdates; @end @@ -26,6 +27,7 @@ @synthesize uiDriver = _uiDriver; @synthesize userDriver = _userDriver; +@synthesize showingUserInitiatedProgress = _showingUserInitiatedProgress; @synthesize canceledCheckForUpdates = _canceledCheckForUpdates; - (instancetype)initWithHost:(SUHost *)host allowsAutomaticUpdates:(BOOL)allowsAutomaticUpdates sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id )userDriver updaterDelegate:(nullable id )updaterDelegate @@ -40,18 +42,8 @@ - (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary *)httpHeaders completion:(SUUpdateDriverCompletion)completionBlock { - [self showUserInitiatedProgress]; - [self.uiDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders includesSkippedUpdates:YES completion:completionBlock]; -} - -- (void)resumeUpdateWithCompletion:(SUUpdateDriverCompletion)completionBlock -{ - [self showUserInitiatedProgress]; - [self.uiDriver resumeUpdateWithCompletion:completionBlock]; -} - -- (void)showUserInitiatedProgress -{ + self.showingUserInitiatedProgress = YES; + [self.userDriver showUserInitiatedUpdateCheckWithCompletion:^(SUUserInitiatedCheckStatus completionStatus) { switch (completionStatus) { case SUUserInitiatedCheckDone: @@ -64,6 +56,13 @@ break; } }]; + + [self.uiDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders includesSkippedUpdates:YES completion:completionBlock]; +} + +- (void)resumeUpdateWithCompletion:(SUUpdateDriverCompletion)completionBlock +{ + [self.uiDriver resumeUpdateWithCompletion:completionBlock]; } - (void)basicDriverIsRequestingAbortUpdateWithError:(nullable NSError *)error @@ -80,7 +79,8 @@ { if (self.canceledCheckForUpdates) { [self abortUpdate]; - } else { + } else if (self.showingUserInitiatedProgress) { + self.showingUserInitiatedProgress = NO; [self.userDriver dismissUserInitiatedUpdateCheck]; } } @@ -92,7 +92,9 @@ - (void)abortUpdateWithError:(nullable NSError *)error { - [self.userDriver dismissUserInitiatedUpdateCheck]; + if (self.showingUserInitiatedProgress) { + [self.userDriver dismissUserInitiatedUpdateCheck]; + } [self.uiDriver abortUpdateWithError:error]; }