From 4d2cf36b614f7c8cf4fcff9b1e46648ebefa51ec Mon Sep 17 00:00:00 2001 From: Lukhnos Liu Date: Mon, 19 Oct 2020 20:09:17 -0700 Subject: [PATCH] Add a preferences key to disable update checks --- Source/AppDelegate.m | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Source/AppDelegate.m b/Source/AppDelegate.m index 73b376bb..409d9d84 100644 --- a/Source/AppDelegate.m +++ b/Source/AppDelegate.m @@ -38,6 +38,7 @@ extern void LTLoadLanguageModel(void); +static NSString *kCheckUpdateAutomatically = @"CheckUpdateAutomatically"; static NSString *kNextUpdateCheckDateKey = @"NextUpdateCheckDate"; static NSString *kUpdateInfoEndpointKey = @"UpdateInfoEndpoint"; static NSString *kUpdateInfoSiteKey = @"UpdateInfoSite"; @@ -61,6 +62,11 @@ static const NSTimeInterval kTimeoutInterval = 60.0; { LTLoadLanguageModel(); + if (![[NSUserDefaults standardUserDefaults] objectForKey:kCheckUpdateAutomatically]) { + [[NSUserDefaults standardUserDefaults] setBool:YES forKey:kCheckUpdateAutomatically]; + [[NSUserDefaults standardUserDefaults] synchronize]; + } + [self checkForUpdate]; } @@ -80,6 +86,10 @@ static const NSTimeInterval kTimeoutInterval = 60.0; // time for update? if (!forced) { + if (![[NSUserDefaults standardUserDefaults] boolForKey:kCheckUpdateAutomatically]) { + return; + } + NSDate *now = [NSDate date]; NSDate *date = [[NSUserDefaults standardUserDefaults] objectForKey:kNextUpdateCheckDateKey]; if (![date isKindOfClass:[NSDate class]]) {