From 55b865fdfdd0dd0496ebbe1d15ad9714f4b6f84b Mon Sep 17 00:00:00 2001 From: phlpsong Date: Tue, 23 Jan 2024 22:17:18 +0800 Subject: [PATCH] fix: revert default disable app workaround and disableAutoSelect --- Easydict/Feature/EventMonitor/EZEventMonitor.m | 7 ------- .../EZDisableAutoSelectTextViewController.m | 5 +++++ .../NewApp/View/SettingView/Tabs/DisabledAppTab.swift | 9 ++++++++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Easydict/Feature/EventMonitor/EZEventMonitor.m b/Easydict/Feature/EventMonitor/EZEventMonitor.m index 102885a35..f3acfe5ab 100644 --- a/Easydict/Feature/EventMonitor/EZEventMonitor.m +++ b/Easydict/Feature/EventMonitor/EZEventMonitor.m @@ -143,15 +143,8 @@ - (EZTriggerType)getAppSelectTextActionType:(NSString *)appBundleID wechat.appBundleID = @"com.tencent.xinWeChat"; wechat.triggerType = EZTriggerTypeDoubleClick | EZTriggerTypeTripleClick; - // https://github.com/tisfeng/Easydict/issues/346 - // Add Easydict self as block app - EZAppModel *selfApp = [[EZAppModel alloc] init]; - selfApp.appBundleID = [[NSBundle mainBundle] bundleIdentifier]; - selfApp.triggerType = EZTriggerTypeNone; - NSArray *defaultAppModels = @[ wechat, - selfApp ]; return defaultAppModels; diff --git a/Easydict/Feature/PerferenceWindow/DisableAutoSelectTextViewController/EZDisableAutoSelectTextViewController.m b/Easydict/Feature/PerferenceWindow/DisableAutoSelectTextViewController/EZDisableAutoSelectTextViewController.m index 39017c32c..86a5c8e56 100644 --- a/Easydict/Feature/PerferenceWindow/DisableAutoSelectTextViewController/EZDisableAutoSelectTextViewController.m +++ b/Easydict/Feature/PerferenceWindow/DisableAutoSelectTextViewController/EZDisableAutoSelectTextViewController.m @@ -254,6 +254,9 @@ - (void)selectApp { NSArray *allowedTypes = @[ UTTypeApplication ]; [openPanel setAllowedContentTypes:allowedTypes]; + // ???: Since [auto select] will cause lag when dragging select apps, I don't know why 😰 + Configuration.shared.disabledAutoSelect = YES; + NSModalResponse result = [openPanel runModal]; if (result == NSModalResponseOK) { NSLog(@"selected URLs: %@", openPanel.URLs); @@ -264,6 +267,8 @@ - (void)selectApp { [self.tableView reloadData]; } + + Configuration.shared.disabledAutoSelect = NO; } - (NSArray *)appModelsFromBundleIDDict:(NSDictionary *)appBundleIDDict { diff --git a/Easydict/NewApp/View/SettingView/Tabs/DisabledAppTab.swift b/Easydict/NewApp/View/SettingView/Tabs/DisabledAppTab.swift index 7d70402ff..e5fa23748 100644 --- a/Easydict/NewApp/View/SettingView/Tabs/DisabledAppTab.swift +++ b/Easydict/NewApp/View/SettingView/Tabs/DisabledAppTab.swift @@ -12,8 +12,13 @@ import SwiftUI private class DisabledAppViewModel: ObservableObject { @Published var appModelList: [EZAppModel] = [] @Published var selectedAppModels: Set = [] - @Published var isImporting = false @Published var isShowImportErrorAlert = false + @Published var isImporting = false { + didSet { + // https://github.com/tisfeng/Easydict/issues/346 + Configuration.shared.disabledAutoSelect = isImporting + } + } init() { fetchDisabledApps() @@ -69,6 +74,7 @@ struct DisabledAppTab: View { allowedContentTypes: [.application], allowsMultipleSelection: true ) { result in +// Configuration.shared.disabledAutoSelect = true switch result { case let .success(urls): disabledAppViewModel.newAppURLsSelected(from: urls) @@ -76,6 +82,7 @@ struct DisabledAppTab: View { print("fileImporter error: \(error)") disabledAppViewModel.isShowImportErrorAlert.toggle() } +// Configuration.shared.disabledAutoSelect = false } .alert(isPresented: $disabledAppViewModel.isShowImportErrorAlert) { Alert(title: Text(""), message: Text("setting.disabled.import_app_error.message"), dismissButton: .default(Text("ok")))