Skip to content

Commit

Permalink
fix: new services were disabled by mistake (#373)
Browse files Browse the repository at this point in the history
  • Loading branch information
tisfeng authored Jan 30, 2024
1 parent 1a89fb9 commit bece937
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions Easydict/Feature/ViewController/Storage/EZLocalStorage.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,26 @@ - (void)setup {
EZWindowType windowType = [number integerValue];
for (EZServiceType serviceType in allServiceTypes) {
EZServiceInfo *serviceInfo = [self serviceInfoWithType:serviceType windowType:windowType];

// New service.
if (!serviceInfo) {
serviceInfo = [[EZServiceInfo alloc] init];
serviceInfo.type = serviceType;
serviceInfo.enabled = NO; // disable new service
serviceInfo.enabled = YES;
serviceInfo.enabledQuery = YES;

// Mini type should keep concise, services <= 4
/**
Fix https://github.com/tisfeng/Easydict/issues/269 and https://github.com/tisfeng/Easydict/issues/372
If there is a new service, we enable it but disable auto query, and add it to the end of the array.
If it is the user's first time, auto query should be all allowed.
*/
if (self.queryCount > 0) {
serviceInfo.enabledQuery = NO;
}

// Mini window should keep concise, so default enabled services should <= 4
if (windowType == EZWindowTypeMini) {
NSArray *defaultEnabledServices = @[
EZServiceTypeAppleDictionary,
Expand All @@ -78,10 +92,6 @@ - (void)setup {
serviceInfo.enabled = [defaultEnabledServices containsObject:serviceType];
}

// There is a very small probability that Volcano webView translator will crash.
if (serviceType != EZServiceTypeVolcano) {
serviceInfo.enabledQuery = YES;
}
[self setServiceInfo:serviceInfo windowType:windowType];
}
}
Expand All @@ -100,10 +110,6 @@ - (void)setup {
NSMutableArray *array = [NSMutableArray arrayWithArray:allStoredServiceTypes];
if (![allStoredServiceTypes isEqualToArray:allServiceTypes]) {
for (EZServiceType type in allServiceTypes) {
/**
If there is a new service, add it to the end of the array.
Fix https://github.com/tisfeng/Easydict/issues/269
*/
if ([allStoredServiceTypes indexOfObject:type] == NSNotFound) {
[array addObject:type];
}
Expand Down

0 comments on commit bece937

Please sign in to comment.