From 8ae30dff44765c1648a4e5af55052b98f36f1f9a Mon Sep 17 00:00:00 2001 From: tisfeng Date: Sun, 28 Jan 2024 10:47:21 +0800 Subject: [PATCH] perf: improve code --- .../NewApp/View/SettingView/Tabs/AboutTab.swift | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Easydict/NewApp/View/SettingView/Tabs/AboutTab.swift b/Easydict/NewApp/View/SettingView/Tabs/AboutTab.swift index 4c68ce1b0..d7a833c07 100644 --- a/Easydict/NewApp/View/SettingView/Tabs/AboutTab.swift +++ b/Easydict/NewApp/View/SettingView/Tabs/AboutTab.swift @@ -59,21 +59,16 @@ struct AboutTab: View { } class CheckUpdaterViewModel: ObservableObject { - @Published var autoChecksForUpdates: Bool = false { + private let updater = GlobalContext.shared.updaterController.updater + + @Published var autoChecksForUpdates = true { didSet { - GlobalContext - .shared - .updaterController - .updater - .automaticallyChecksForUpdates = autoChecksForUpdates + updater.automaticallyChecksForUpdates = autoChecksForUpdates } } init() { - GlobalContext - .shared - .updaterController - .updater + updater .publisher(for: \.automaticallyChecksForUpdates) .assign(to: &$autoChecksForUpdates) }