Skip to content

Commit

Permalink
perf: add updater in Configuration for easy outside use
Browse files Browse the repository at this point in the history
  • Loading branch information
tisfeng committed Jan 28, 2024
1 parent 8ae30df commit 8a3b626
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
6 changes: 4 additions & 2 deletions Easydict/Feature/Configuration/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@ let kHideMenuBarIconKey = "EZConfiguration_kHideMenuBarIconKey"
@DefaultsWrapper(.launchAtStartup)
var launchAtStartup: Bool

let updater = GlobalContext.shared.updaterController.updater

var automaticallyChecksForUpdates: Bool {
get {
GlobalContext.shared.updaterController.updater.automaticallyChecksForUpdates
updater.automaticallyChecksForUpdates
}
set {
GlobalContext.shared.updaterController.updater.automaticallyChecksForUpdates = newValue
updater.automaticallyChecksForUpdates = newValue
logSettings(["automatically_checks_for_updates": newValue])
}
}
Expand Down
6 changes: 2 additions & 4 deletions Easydict/NewApp/View/MenuItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ final class MenuItemStore: ObservableObject {
@Published var canCheckForUpdates = false

init() {
GlobalContext.shared
.updaterController
.updater
Configuration.shared.updater
.publisher(for: \.canCheckForUpdates)
.assign(to: &$canCheckForUpdates)
}
Expand Down Expand Up @@ -171,7 +169,7 @@ struct MenuItemView: View {
private var checkUpdateItem: some View {
Button("check_updates") {
NSLog("检查更新")
GlobalContext.shared.updaterController.updater.checkForUpdates()
Configuration.shared.updater.checkForUpdates()
}.disabled(!store.canCheckForUpdates)
}

Expand Down
2 changes: 1 addition & 1 deletion Easydict/NewApp/View/SettingView/Tabs/AboutTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct AboutTab: View {
}

class CheckUpdaterViewModel: ObservableObject {
private let updater = GlobalContext.shared.updaterController.updater
private let updater = Configuration.shared.updater

@Published var autoChecksForUpdates = true {
didSet {
Expand Down
1 change: 0 additions & 1 deletion Easydict/NewApp/View/SettingView/Tabs/PrivacyTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ struct PrivacyTab: View {
}

@Default(.allowCrashLog) private var allowCollectCrashLog

@Default(.allowAnalytics) private var allowCollectAnalytics
}

Expand Down

0 comments on commit 8a3b626

Please sign in to comment.