Change updateInProgress to canCheckForUpdates

This more accurately reflects its intended purpose. From the beginning,
the user cannot check for updates until the updater is ready;
however this doesn't mean that the update is in progress.
This commit is contained in:
Zorg committed 2016-04-09 11:39:02 -04:00
1 parent 933504263a
commit 1bb301e82a
10 files changed
+26 -26

No files matched your search

+1 -1
View File
@@ -66,7 +66,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
- (BOOL)validateMenuItem:(NSMenuItem *)item
{
if ([item action] == @selector(checkForUpdates:)) {
return !self.userDriver.updateInProgress;
return self.userDriver.canCheckForUpdates;
}
return YES;
}
+4 -4
View File
@@ -67,16 +67,16 @@
return self.coreComponent.idlesOnUpdateChecks;
}
- (void)showUpdateInProgress:(BOOL)isUpdateInProgress
- (void)showCanCheckForUpdates:(BOOL)canCheckForUpdates
{
dispatch_async(dispatch_get_main_queue(), ^{
[self.coreComponent showUpdateInProgress:isUpdateInProgress];
[self.coreComponent showCanCheckForUpdates:canCheckForUpdates];
});
}
- (BOOL)isUpdateInProgress
- (BOOL)canCheckForUpdates
{
return self.coreComponent.updateInProgress;
return self.coreComponent.canCheckForUpdates;
}
#pragma mark Check Updates Timer
+1 -1
View File
@@ -27,7 +27,7 @@
A typical application may rely on this property for its check for updates menu item validation
*/
@property (nonatomic, readonly, getter=isUpdateInProgress) BOOL updateInProgress;
@property (nonatomic, readonly) BOOL canCheckForUpdates;
/*!
Indicates whether or not a currently pending update check will be initiated in the future
+3 -3
View File
@@ -228,6 +228,8 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
if (firingImmediately) {
[self checkForUpdatesInBackground];
} else {
[self.userDriver showCanCheckForUpdates:YES];
[self retrieveNextUpdateCheckInterval:^(NSTimeInterval updateCheckInterval) {
// How long has it been since last we checked for an update?
NSDate *lastCheckDate = [self lastUpdateCheckDate];
@@ -398,8 +400,6 @@ static void SUCheckForUpdatesInBgReachabilityCheck(__weak SUUpdater *updater, id
[self scheduleNextUpdateCheck];
return;
}
[self.userDriver showUpdateInProgress:YES];
[self checkIfConfiguredProperly];
@@ -411,7 +411,6 @@ static void SUCheckForUpdatesInBgReachabilityCheck(__weak SUUpdater *updater, id
SUUpdater *strongSelf = weakSelf;
if (strongSelf != nil) {
strongSelf.driver = nil;
[strongSelf.userDriver showUpdateInProgress:NO];
[strongSelf updateLastUpdateCheckDate];
[strongSelf scheduleNextUpdateCheckFiringImmediately:shouldShowUpdateImmediately];
}
@@ -420,6 +419,7 @@ static void SUCheckForUpdatesInBgReachabilityCheck(__weak SUUpdater *updater, id
[SUProbeInstallStatus probeInstallerInProgressForHost:self.host completion:^(BOOL success) {
dispatch_async(dispatch_get_main_queue(), ^{
SUUpdater *strongSelf = weakSelf;
[strongSelf.userDriver showCanCheckForUpdates:NO];
if (strongSelf != nil) {
if (!success) {
[strongSelf.driver checkForUpdatesAtAppcastURL:theFeedURL withUserAgent:[strongSelf userAgentString] httpHeaders:[strongSelf httpHeaders] completion:completionBlock];
+3 -3
View File
@@ -32,14 +32,14 @@ NS_ASSUME_NONNULL_BEGIN
@protocol SUUserDriver <NSObject>
/*!
* Show that an update is or is not in progress.
* Show that an update can be checked by the user or not
*
* A client may choose to update the interface letting the user know the updater is or is not busy.
* A client may choose to update the interface letting the user know if they can check for updates.
* For example, this can be used for menu item validation on the "Check for Updates" action.
*
* This can be called from any thread.
*/
- (void)showUpdateInProgress:(BOOL)isUpdateInProgress;
- (void)showCanCheckForUpdates:(BOOL)canCheckForUpdates;
/*!
* Idle on timed updater checks.
+2 -2
View File
@@ -22,9 +22,9 @@ SU_EXPORT @interface SUUserDriverCoreComponent : NSObject
@property (nonatomic, readonly) BOOL idlesOnUpdateChecks;
- (void)showUpdateInProgress:(BOOL)isUpdateInProgress;
- (void)showCanCheckForUpdates:(BOOL)canCheckForUpdates;
@property (nonatomic, readonly, getter=isUpdateInProgress) BOOL updateInProgress;
@property (nonatomic, readonly) BOOL canCheckForUpdates;
@property (nonatomic, readonly) BOOL willInitiateNextUpdateCheck;
+6 -6
View File
@@ -17,7 +17,7 @@
@interface SUUserDriverCoreComponent ()
@property (nonatomic) BOOL idlesOnUpdateChecks;
@property (nonatomic) BOOL updateInProgress;
@property (nonatomic) BOOL canCheckForUpdates;
@property (nonatomic) NSTimer *checkUpdateTimer;
@property (nonatomic, copy) void (^checkForUpdatesReply)(SUUpdateCheckTimerStatus);
@@ -33,7 +33,7 @@
@synthesize delegate = _delegate;
@synthesize idlesOnUpdateChecks = _idlesOnUpdateChecks;
@synthesize updateInProgress = _updateInProgress;
@synthesize canCheckForUpdates = _canCheckForUpdates;
@synthesize checkUpdateTimer = _checkUpdateTimer;
@synthesize checkForUpdatesReply = _checkForUpdatesReply;
@synthesize installUpdateHandler = _installUpdateHandler;
@@ -59,9 +59,9 @@
self.idlesOnUpdateChecks = shouldIdleOnUpdateChecks;
}
- (void)showUpdateInProgress:(BOOL)isUpdateInProgress
- (void)showCanCheckForUpdates:(BOOL)canCheckForUpdates
{
self.updateInProgress = isUpdateInProgress;
self.canCheckForUpdates = canCheckForUpdates;
}
#pragma mark Check Updates Timer
@@ -212,8 +212,6 @@
{
// Note: self.idlesOnUpdateChecks is intentionally not touched in case this instance is re-used
self.updateInProgress = NO;
[self acceptAcknowledgement];
[self cancelUpdateCheckStatus];
[self cancelDownloadStatus];
@@ -236,6 +234,8 @@
// Dismiss the installation normally
[self dismissUpdateInstallation];
self.canCheckForUpdates = YES;
}
@end
+4 -4
View File
@@ -115,16 +115,16 @@
return self.coreComponent.idlesOnUpdateChecks;
}
- (void)showUpdateInProgress:(BOOL)isUpdateInProgress
- (void)showCanCheckForUpdates:(BOOL)canCheckForUpdates
{
dispatch_async(dispatch_get_main_queue(), ^{
[self.coreComponent showUpdateInProgress:isUpdateInProgress];
[self.coreComponent showCanCheckForUpdates:canCheckForUpdates];
});
}
- (BOOL)isUpdateInProgress
- (BOOL)canCheckForUpdates
{
return self.coreComponent.updateInProgress;
return self.coreComponent.canCheckForUpdates;
}
#pragma mark Check Updates Timer
@@ -153,7 +153,7 @@
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
{
if (menuItem.action == @selector(checkForUpdates:)) {
return (self.userDriver != nil && !self.userDriver.updateInProgress);
return (self.userDriver != nil && self.userDriver.canCheckForUpdates);
} else if (menuItem.action == @selector(invalidateConnection:)) {
return (self.connection != nil);
}
+1 -1
View File
@@ -19,7 +19,7 @@
@implementation SUUselessUserDriver
- (void)showUpdateInProgress:(BOOL)__unused isUpdateInProgress {}
- (void)showCanCheckForUpdates:(BOOL)__unused canCheckForUpdates {}
- (void)idleOnUpdateChecks:(BOOL)__unused shouldIdleOnUpdateChecks {}