misc: delete reload disposables
This commit is contained in:
parent
4c08dae551
commit
f4842438b7
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue