From 96d88858f24d77d7d4fc18afc7a0031d61ed6f12 Mon Sep 17 00:00:00 2001 From: Lucas Derraugh Date: Sun, 14 Nov 2021 16:11:44 -0500 Subject: [PATCH] Don't force Sparkle updates in background #738 (#776) --- GitUp/Application/AboutWindowController.h | 1 - GitUp/Application/AboutWindowController.m | 10 +++------ GitUp/Application/AppDelegate.m | 27 ++++------------------- 3 files changed, 7 insertions(+), 31 deletions(-) diff --git a/GitUp/Application/AboutWindowController.h b/GitUp/Application/AboutWindowController.h index a8187ecc..4d37f563 100644 --- a/GitUp/Application/AboutWindowController.h +++ b/GitUp/Application/AboutWindowController.h @@ -10,7 +10,6 @@ NS_ASSUME_NONNULL_BEGIN @interface AboutWindowController : NSWindowController -@property(assign, nonatomic, readwrite) BOOL updatePending; @end NS_ASSUME_NONNULL_END diff --git a/GitUp/Application/AboutWindowController.m b/GitUp/Application/AboutWindowController.m index ba1dbebe..e7fbb183 100644 --- a/GitUp/Application/AboutWindowController.m +++ b/GitUp/Application/AboutWindowController.m @@ -20,19 +20,15 @@ - (instancetype)init { - (void)windowDidLoad { [super windowDidLoad]; - [self populateWithDataWhenUpdateIsPending:self.updatePending]; + [self configureUI]; } -- (void)populateWithDataWhenUpdateIsPending:(BOOL)updatePending { +- (void)configureUI { NSString* version = nil; #if DEBUG version = @"DEBUG"; #else - if (updatePending) { - version = NSLocalizedString(@"Update Pending", nil); - } else { - version = [NSString stringWithFormat:NSLocalizedString(@"Version %@ (%@)", nil), [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"], [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]]; - } + version = [NSString stringWithFormat:NSLocalizedString(@"Version %@ (%@)", nil), [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"], [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]]; #endif self.versionTextField.stringValue = version; self.copyrightTextField.stringValue = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSHumanReadableCopyright"]; diff --git a/GitUp/Application/AppDelegate.m b/GitUp/Application/AppDelegate.m index 2efe0c17..8430f33b 100644 --- a/GitUp/Application/AppDelegate.m +++ b/GitUp/Application/AppDelegate.m @@ -51,7 +51,6 @@ @interface AppDelegate () @implementation AppDelegate { SUUpdater* _updater; - BOOL _updatePending; BOOL _manualCheck; CFMessagePortRef _messagePort; @@ -212,9 +211,8 @@ - (void)applicationDidFinishLaunching:(NSNotification*)notification { if (![[NSUserDefaults standardUserDefaults] boolForKey:kUserDefaultsKey_DisableSparkle]) { _updater = [SUUpdater sharedUpdater]; _updater.delegate = self; - _updater.automaticallyChecksForUpdates = NO; + _updater.automaticallyChecksForUpdates = YES; _updater.sendsSystemProfile = NO; - _updater.automaticallyDownloadsUpdates = YES; _manualCheck = NO; [_updater checkForUpdatesInBackground]; @@ -382,9 +380,9 @@ - (NSDictionary*)_processToolCommand:(NSDictionary*)input { #pragma mark - Actions -- (BOOL)validateUserInterfaceItem:(id)anItem { - if (anItem.action == @selector(checkForUpdates:)) { - return _updater && !_updatePending && ![_updater updateInProgress]; +- (BOOL)validateMenuItem:(NSMenuItem *)menuItem { + if (menuItem.action == @selector(checkForUpdates:)) { + return [_updater validateMenuItem:menuItem]; } return YES; } @@ -406,7 +404,6 @@ - (IBAction)viewIssues:(id)sender { } - (IBAction)showAboutPanel:(id)sender { - self.aboutWindowController.updatePending = _updatePending; [self.aboutWindowController showWindow:nil]; } @@ -562,14 +559,6 @@ - (NSString*)feedURLStringForUpdater:(SUUpdater*)updater { - (void)updater:(SUUpdater*)updater didFindValidUpdate:(SUAppcastItem*)item { NSString* channel = [[NSUserDefaults standardUserDefaults] stringForKey:kUserDefaultsKey_ReleaseChannel]; XLOG_INFO(@"Did find app update on channel '%@' for version %@", channel, item.versionString); - if (_manualCheck) { - NSAlert* alert = [[NSAlert alloc] init]; - alert.messageText = NSLocalizedString(@"A GitUp update is available!", nil); - alert.informativeText = NSLocalizedString(@"The update will download automatically in the background and be installed when you quit GitUp.", nil); - [alert addButtonWithTitle:NSLocalizedString(@"OK", nil)]; - alert.type = kGIAlertType_Note; - [alert runModal]; - } } - (void)updaterDidNotFindUpdate:(SUUpdater*)updater { @@ -595,12 +584,4 @@ - (void)updater:(SUUpdater*)updater willInstallUpdate:(SUAppcastItem*)item { XLOG_INFO(@"Installing app update for version %@", item.versionString); } -- (void)updater:(SUUpdater*)updater willInstallUpdateOnQuit:(SUAppcastItem*)item immediateInstallationInvocation:(NSInvocation*)invocation { - XLOG_INFO(@"Will install app update for version %@ on quit", item.versionString); - _updatePending = YES; - [self _showNotificationWithTitle:NSLocalizedString(@"Update Available", nil) - action:NULL - message:NSLocalizedString(@"Relaunch GitUp to update to version %@ (%@).", nil), item.displayVersionString, item.versionString]; -} - @end