Skip to content

Commit

Permalink
perf: replace custom user default with Spark automaticallyChecksForUp…
Browse files Browse the repository at this point in the history
…dates
  • Loading branch information
tisfeng committed Dec 11, 2023
1 parent a81fc4b commit 279275c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Easydict/App/Info-debug.plist
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,7 @@
<string>https://raw.githubusercontent.com/tisfeng/Easydict/main/appcast.xml</string>
<key>SUPublicEDKey</key>
<string>9Ee1FtAsmJHFD79H4bToJhAOJmTtkTYIUDr23ofEWiU=</string>
<key>SUEnableAutomaticChecks</key>
<true/>
</dict>
</plist>
2 changes: 2 additions & 0 deletions Easydict/App/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,7 @@
<string>https://raw.githubusercontent.com/tisfeng/Easydict/main/appcast.xml</string>
<key>SUPublicEDKey</key>
<string>9Ee1FtAsmJHFD79H4bToJhAOJmTtkTYIUDr23ofEWiU=</string>
<key>SUEnableAutomaticChecks</key>
<true/>
</dict>
</plist>
15 changes: 8 additions & 7 deletions Easydict/Feature/Configuration/EZConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -59,6 +58,7 @@
@interface EZConfiguration ()

@property (nonatomic, strong) AppDelegate *appDelegate;
@property (nonatomic, strong) SPUUpdater *updater;

@end

Expand Down Expand Up @@ -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];
Expand All @@ -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
Expand Down Expand Up @@ -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)}];
}
Expand Down

0 comments on commit 279275c

Please sign in to comment.