Remove asking user updater driver if it's showing alerts modally

non-void/synchronous calls over XPC don't work properly, and
these methods don't seem very proper architecture wise anyway.
A proper solution will be needed for notifying the delegate of modal alerts
This commit is contained in:
Zorg committed 2016-02-22 23:21:27 -05:00
1 parent 308cfe36cf
commit a6d6e31b2c
3 files changed
+12 -18

No files matched your search

+12 -5
View File
@@ -53,7 +53,7 @@
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:self.updater];
if (!self.automaticallyInstallUpdates) {
[self showNoticeModally:[self.updater.userUpdaterDriver showsUpdateNotFoundModally] noticeHandler:^{
[self showNotice:^{
[self.updater.userUpdaterDriver showUpdateNotFound];
}];
@@ -152,22 +152,29 @@
- (void)abortUpdateWithError:(NSError *)error
{
[self showNoticeModally:[self.updater.userUpdaterDriver showsUpdateErrorModally] noticeHandler:^{
[self showNotice:^{
[self.updater.userUpdaterDriver showUpdaterError:error];
}];
[super abortUpdateWithError:error];
}
- (void)showNoticeModally:(BOOL)modally noticeHandler:(void (^)(void))noticeHandler
#warning think of a proper solution..
// These delegate methods to show a modal alert are troublesome
// The user driver may not actually show a modal alert (although our default provided one does)
// We also don't want the user driver to have a reference to the delegate because the user driver
// can live in a separate process, so that's no good either. The user driver methods all need to be
// async and have void return types for XPC, so asking the user driver if it will show an alert modally can get complex
// Furthermore it's possible the user driver can bring up a modal alert in other scenarios out of our control
- (void)showNotice:(void (^)(void))noticeHandler
{
if (modally && [[self.updater delegate] respondsToSelector:@selector(updaterWillShowModalAlert:)]) {
if ([[self.updater delegate] respondsToSelector:@selector(updaterWillShowModalAlert:)]) {
[[self.updater delegate] updaterWillShowModalAlert:self.updater];
}
noticeHandler();
if (modally && [[self.updater delegate] respondsToSelector:@selector(updaterDidShowModalAlert:)]) {
if ([[self.updater delegate] respondsToSelector:@selector(updaterDidShowModalAlert:)]) {
[[self.updater delegate] updaterDidShowModalAlert:self.updater];
}
}
-3
View File
@@ -28,10 +28,7 @@
- (void)showAutomaticUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem reply:(void (^)(SUAutomaticInstallationChoice))reply;
- (void)showUpdateNotFound;
- (BOOL)showsUpdateNotFoundModally;
- (void)showUpdaterError:(NSError *)error;
- (BOOL)showsUpdateErrorModally;
- (void)showDownloadInitiatedWithCancelCallback:(void (^)(void))cancelDownload;
- (void)showDownloadDidReceiveResponse:(NSURLResponse *)response;
@@ -54,21 +54,11 @@
NSLog(@":( there was no new update");
}
- (BOOL)showsUpdateNotFoundModally
{
return NO;
}
- (void)showUpdaterError:(NSError *)error
{
NSLog(@"Update error: %@", error);
}
- (BOOL)showsUpdateErrorModally
{
return NO;
}
- (void)showDownloadInitiatedWithCancelCallback:(void (^)(void))__unused cancelDownload
{
NSLog(@"Downloading update...");