Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: new services were disabled by mistake #373

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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