Skip to content

Commit

Permalink
fix: setting crash after uninstall app in disabled app list
Browse files Browse the repository at this point in the history
  • Loading branch information
phlpsong committed Jan 25, 2024
1 parent 1dcf8d6 commit 4da263a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
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];
}
}
}


#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

0 comments on commit 4da263a

Please sign in to comment.