Skip to content

Commit

Permalink
fix: setting crash after uninstall app in disabled app list (#364)
Browse files Browse the repository at this point in the history
Co-authored-by: Tisfeng <[email protected]>
  • Loading branch information
phlpsong and tisfeng authored Jan 26, 2024
1 parent a7bb785 commit b6974d1
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 b6974d1

Please sign in to comment.