From f4842438b78071e55a7f72ce398e4b131dc528d8 Mon Sep 17 00:00:00 2001 From: mrFq1 <1xxbx0il0@mozmail.com> Date: Sun, 6 Oct 2024 19:44:29 +0800 Subject: [PATCH] misc: delete reload disposables --- ClashX/Dashboard/DashboardViewContoller.swift | 4 --- ClashX/ViewControllers/DashboardManager.swift | 32 ------------------- 2 files changed, 36 deletions(-) diff --git a/ClashX/Dashboard/DashboardViewContoller.swift b/ClashX/Dashboard/DashboardViewContoller.swift index efd68fa43..d82cc88b5 100644 --- a/ClashX/Dashboard/DashboardViewContoller.swift +++ b/ClashX/Dashboard/DashboardViewContoller.swift @@ -32,10 +32,6 @@ public class DashboardWindowController: NSWindowController { ConfigManager.shared.overrideApiURL = .init(string: apiURL) ConfigManager.shared.overrideSecret = secret } - - public func reload() { -#warning("todo reload dashboard") - } } extension DashboardWindowController: NSWindowDelegate { diff --git a/ClashX/ViewControllers/DashboardManager.swift b/ClashX/ViewControllers/DashboardManager.swift index 6eaf6b925..fee0a8b87 100644 --- a/ClashX/ViewControllers/DashboardManager.swift +++ b/ClashX/ViewControllers/DashboardManager.swift @@ -26,21 +26,15 @@ class DashboardManager: NSObject { if newValue { clashWebWindowController?.close() } else { - deinitNotifications() dashboardWindowController?.close() } } } var dashboardWindowController: DashboardWindowController? - private var disposables = [Disposable]() - - var clashWebWindowController: ClashWebViewWindowController? func show(_ sender: NSMenuItem?) { - initNotifications() - if useSwiftUI { clashWebWindowController = nil showSwiftUIWindow(sender) @@ -61,16 +55,6 @@ class DashboardManager: NSObject { clashWebWindowController?.showWindow(sender) } - func deinitNotifications() { - disposables.forEach { - $0.dispose() - } - disposables.removeAll() - } - - deinit { - deinitNotifications() - } } extension DashboardManager { @@ -88,20 +72,4 @@ extension DashboardManager { dashboardWindowController?.showWindow(sender) } - func initNotifications() { - guard useSwiftUI, disposables.count == 0 else { return } - - let n1 = NotificationCenter.default.rx.notification(.configFileChange).subscribe { - [weak self] _ in - self?.dashboardWindowController?.reload() - } - - let n2 = NotificationCenter.default.rx.notification(.reloadDashboard).subscribe { - [weak self] _ in - self?.dashboardWindowController?.reload() - } - disposables.append(n1) - disposables.append(n2) - } - }