From 279275ce578068a4269ca54c8936f53149a9e47b Mon Sep 17 00:00:00 2001 From: tisfeng Date: Mon, 11 Dec 2023 18:42:07 +0800 Subject: [PATCH] perf: replace custom user default with Spark automaticallyChecksForUpdates --- Easydict/App/Info-debug.plist | 2 ++ Easydict/App/Info.plist | 2 ++ Easydict/Feature/Configuration/EZConfiguration.m | 15 ++++++++------- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Easydict/App/Info-debug.plist b/Easydict/App/Info-debug.plist index 554a2caea..defc09926 100644 --- a/Easydict/App/Info-debug.plist +++ b/Easydict/App/Info-debug.plist @@ -64,5 +64,7 @@ https://raw.githubusercontent.com/tisfeng/Easydict/main/appcast.xml SUPublicEDKey 9Ee1FtAsmJHFD79H4bToJhAOJmTtkTYIUDr23ofEWiU= + SUEnableAutomaticChecks + diff --git a/Easydict/App/Info.plist b/Easydict/App/Info.plist index 8cb85113c..6e735f833 100644 --- a/Easydict/App/Info.plist +++ b/Easydict/App/Info.plist @@ -64,5 +64,7 @@ https://raw.githubusercontent.com/tisfeng/Easydict/main/appcast.xml SUPublicEDKey 9Ee1FtAsmJHFD79H4bToJhAOJmTtkTYIUDr23ofEWiU= + SUEnableAutomaticChecks + diff --git a/Easydict/Feature/Configuration/EZConfiguration.m b/Easydict/Feature/Configuration/EZConfiguration.m index be94bd899..49e38ac7b 100644 --- a/Easydict/Feature/Configuration/EZConfiguration.m +++ b/Easydict/Feature/Configuration/EZConfiguration.m @@ -49,7 +49,6 @@ static NSString *const kShortcutSelectTranslateWindowTypeKey = @"EZConfiguration_kShortcutSelectTranslateWindowTypeKey"; static NSString *const kMouseSelectTranslateWindowTypeKey = @"EZConfiguration_kMouseSelectTranslateWindowTypeKey"; static NSString *const kWindowFrameKey = @"EZConfiguration_kWindowFrameKey"; -static NSString *const kAutomaticallyChecksForUpdatesKey = @"EZConfiguration_kAutomaticallyChecksForUpdatesKey"; static NSString *const kAdjustPopButtomOriginKey = @"EZConfiguration_kAdjustPopButtomOriginKey"; static NSString *const kAllowCrashLogKey = @"EZConfiguration_kAllowCrashLogKey"; static NSString *const kAllowAnalyticsKey = @"EZConfiguration_kAllowAnalyticsKey"; @@ -59,6 +58,7 @@ @interface EZConfiguration () @property (nonatomic, strong) AppDelegate *appDelegate; +@property (nonatomic, strong) SPUUpdater *updater; @end @@ -117,7 +117,6 @@ - (void)setup { self.fixedWindowPosition = [NSUserDefaults mm_readInteger:kShowFixedWindowPositionKey defaultValue:EZShowWindowPositionRight]; self.mouseSelectTranslateWindowType = [NSUserDefaults mm_readInteger:kMouseSelectTranslateWindowTypeKey defaultValue:EZWindowTypeMini]; self.shortcutSelectTranslateWindowType = [NSUserDefaults mm_readInteger:kShortcutSelectTranslateWindowTypeKey defaultValue:EZWindowTypeFixed]; - self.automaticallyChecksForUpdates = [NSUserDefaults mm_readBool:kAutomaticallyChecksForUpdatesKey defaultValue:YES]; self.adjustPopButtomOrigin = [NSUserDefaults mm_readBool:kAdjustPopButtomOriginKey defaultValue:NO]; self.allowCrashLog = [NSUserDefaults mm_readBool:kAllowCrashLogKey defaultValue:YES]; self.allowAnalytics = [NSUserDefaults mm_readBool:kAllowAnalyticsKey defaultValue:YES]; @@ -132,7 +131,11 @@ - (BOOL)launchAtStartup { } - (BOOL)automaticallyChecksForUpdates { - return self.appDelegate.updaterController.updater.automaticallyChecksForUpdates; + return self.updater.automaticallyChecksForUpdates; +} + +- (SPUUpdater *)updater { + return self.appDelegate.updaterController.updater; } #pragma mark - setter @@ -216,10 +219,8 @@ - (void)setLaunchAtStartup:(BOOL)launchAtStartup { [self logSettings:@{@"launch_at_startup" : @(launchAtStartup)}]; } -- (void)setAutomaticallyChecksForUpdates:(BOOL)automaticallyChecksForUpdates { - [NSUserDefaults mm_write:@(automaticallyChecksForUpdates) forKey:kAutomaticallyChecksForUpdatesKey]; - - self.appDelegate.updaterController.updater.automaticallyChecksForUpdates = automaticallyChecksForUpdates; +- (void)setAutomaticallyChecksForUpdates:(BOOL)automaticallyChecksForUpdates { + self.updater.automaticallyChecksForUpdates = automaticallyChecksForUpdates; [self logSettings:@{@"automatically_checks_for_updates" : @(automaticallyChecksForUpdates)}]; }