Skip to content

Commit

Permalink
Override scheduler setters to report status automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
Giorgio Calderolla committed May 6, 2014
1 parent 3b7b552 commit 9ba2e04
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions CTCScheduler.m
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ - (void)preventAppNap {
}
}

- (void)setChecking:(BOOL)checking {
_checking = checking;
[self reportStatus];
}

- (void)setPolling:(BOOL)polling {
_polling = polling;
[self reportStatus];
}

- (void)checkFeed {
// Don't check twice simultaneously
if (self.isChecking) return;
Expand All @@ -86,8 +96,6 @@ - (void)checkFeed {

self.checking = YES;

[self reportStatus];

// Check the feed
__weak typeof(self) weakSelf = self;
[self callFeedCheckerWithReplyHandler:^(NSArray *downloadedFeedFiles,
Expand Down Expand Up @@ -125,7 +133,6 @@ - (void)callFeedCheckerWithReplyHandler:(CTCFeedCheckCompletionHandler)replyHand
- (void)handleFeedCheckCompletion:(BOOL)wasSuccessful {
self.checking = NO;

[self reportStatus];
[NSNotificationCenter.defaultCenter postNotificationName:kCTCSchedulerLastUpdateStatusNotificationName
object:self
userInfo:@{@"successful": @(wasSuccessful),
Expand All @@ -143,8 +150,6 @@ - (void)reportStatus {

- (void)togglePause {
self.polling = !self.isPolling;

[self reportStatus];

// If we have just been set to polling, poll immediately
if (self.isPolling) [self fireTimerNow];
Expand Down

0 comments on commit 9ba2e04

Please sign in to comment.