Subscribe to checkForUpdatesCommand's return value.

This commit is contained in:
Cheng Zhao 2014-01-31 21:31:42 +08:00
parent 73ec7783af
commit 8ee1e1d208

View file

@ -37,6 +37,12 @@ void AutoUpdater::SetFeedURL(const std::string& feed) {
NSURL* url = [NSURL URLWithString:base::SysUTF8ToNSString(feed)]; NSURL* url = [NSURL URLWithString:base::SysUTF8ToNSString(feed)];
NSURLRequest* urlRequest = [NSURLRequest requestWithURL:url]; NSURLRequest* urlRequest = [NSURLRequest requestWithURL:url];
g_updater = [[SQRLUpdater alloc] initWithUpdateRequest:urlRequest]; g_updater = [[SQRLUpdater alloc] initWithUpdateRequest:urlRequest];
}
}
// static
void AutoUpdater::CheckForUpdates() {
RACSignal* signal = [g_updater.checkForUpdatesCommand execute:nil];
AutoUpdaterDelegate* delegate = GetDelegate(); AutoUpdaterDelegate* delegate = GetDelegate();
if (!delegate) if (!delegate)
@ -44,7 +50,7 @@ void AutoUpdater::SetFeedURL(const std::string& feed) {
// Subscribe to events. // Subscribe to events.
__block bool has_update = false; __block bool has_update = false;
[g_updater.updates subscribeNext:^(SQRLDownloadedUpdate* downloadedUpdate) { [signal subscribeNext:^(SQRLDownloadedUpdate* downloadedUpdate) {
has_update = true; has_update = true;
// There is a new update that has been downloaded. // There is a new update that has been downloaded.
@ -65,12 +71,6 @@ void AutoUpdater::SetFeedURL(const std::string& feed) {
delegate->OnUpdateNotAvailable(); delegate->OnUpdateNotAvailable();
has_update = false; has_update = false;
}]; }];
}
}
// static
void AutoUpdater::CheckForUpdates() {
[g_updater.checkForUpdatesCommand execute:nil];
} }
} // namespace auto_updater } // namespace auto_updater