Skip to content

Commit

Permalink
Merge branch 'meta-dev' into meta
Browse files Browse the repository at this point in the history
  • Loading branch information
mrFq1 committed Oct 6, 2024
2 parents e9a8e7e + f484243 commit 0dae0bb
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 36 deletions.
4 changes: 0 additions & 4 deletions ClashX/Dashboard/DashboardViewContoller.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ public class DashboardWindowController: NSWindowController {
ConfigManager.shared.overrideApiURL = .init(string: apiURL)
ConfigManager.shared.overrideSecret = secret
}

public func reload() {
NotificationCenter.default.post(name: .reloadDashboard, object: nil)
}
}

extension DashboardWindowController: NSWindowDelegate {
Expand Down
32 changes: 0 additions & 32 deletions ClashX/ViewControllers/DashboardManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -61,16 +55,6 @@ class DashboardManager: NSObject {
clashWebWindowController?.showWindow(sender)
}

func deinitNotifications() {
disposables.forEach {
$0.dispose()
}
disposables.removeAll()
}

deinit {
deinitNotifications()
}
}

extension DashboardManager {
Expand All @@ -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)
}

}

0 comments on commit 0dae0bb

Please sign in to comment.