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: setting crash after uninstall app in disabled app list #364

Merged
merged 2 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ - (void)viewDidLoad {
}

- (void)setup {
self.appModelList = [[EZLocalStorage.shared selectTextTypeAppModelList] mutableCopy];
[self setupAppModelList];

[self.titleTextField mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.right.inset(kMargin + 5); // ???: Why is the actual inset is 18?
Expand All @@ -78,6 +78,18 @@ - (void)setup {
}];
}

- (void)setupAppModelList {
self.appModelList = [[NSMutableArray alloc] init];
NSArray<EZAppModel *> *allAppModelList = [EZLocalStorage.shared selectTextTypeAppModelList];
NSWorkspace* workspace = [NSWorkspace sharedWorkspace];
for (EZAppModel *appModel in allAppModelList) {
NSURL *appURL = [workspace URLForApplicationWithBundleIdentifier:appModel.appBundleID];
if (appURL) {
[self.appModelList addObject:appModel];
}
tisfeng marked this conversation as resolved.
Show resolved Hide resolved
}
}


#pragma mark - Getter && Setter

Expand Down
7 changes: 6 additions & 1 deletion Easydict/NewApp/View/SettingView/Tabs/DisabledAppTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ private class DisabledAppViewModel: ObservableObject {
}

func fetchDisabledApps() {
appModelList = EZLocalStorage.shared().selectTextTypeAppModelList
let allAppModelList = EZLocalStorage.shared().selectTextTypeAppModelList

appModelList = allAppModelList.compactMap { appModel in
let url = NSWorkspace.shared.urlForApplication(withBundleIdentifier: appModel.appBundleID)
return url == nil ? nil : appModel
}
}

func saveDisabledApps() {
Expand Down