mirror of
https://github.com/yJason/ClashX-Dashboard.git
synced 2026-03-01 00:35:19 +08:00
fix: sidebar default selection
This commit is contained in:
+4
-7
@@ -13,10 +13,10 @@ struct SidebarView: View {
|
||||
private let connsQueue = DispatchQueue(label: "thread-safe-connsQueue", attributes: .concurrent)
|
||||
private let timer = Timer.publish(every: 1, on: .main, in: .default).autoconnect()
|
||||
|
||||
@State private var sidebarSelectionName: String? = "Overview"
|
||||
@State private var sidebarSelectionName: SidebarItem?
|
||||
|
||||
var body: some View {
|
||||
ScrollViewReader { scrollViewProxy in
|
||||
Group {
|
||||
SidebarListView(selectionName: $sidebarSelectionName)
|
||||
}
|
||||
.environmentObject(clashApiDatasStorage.overviewData)
|
||||
@@ -27,8 +27,6 @@ struct SidebarView: View {
|
||||
ConfigManager.selectLoggingApiLevel = .info
|
||||
}
|
||||
|
||||
sidebarItemChanged(sidebarSelectionName)
|
||||
|
||||
clashApiDatasStorage.resetStreamApi()
|
||||
connsQueue.sync {
|
||||
clashApiDatasStorage.connsStorage.conns
|
||||
@@ -57,9 +55,8 @@ struct SidebarView: View {
|
||||
}
|
||||
}
|
||||
|
||||
func sidebarItemChanged(_ name: String?) {
|
||||
guard let str = name,
|
||||
let item = SidebarItem(rawValue: str) else { return }
|
||||
func sidebarItemChanged(_ item: SidebarItem?) {
|
||||
guard let item else { return }
|
||||
|
||||
NotificationCenter.default.post(name: .sidebarItemChanged, object: nil, userInfo: ["item": item])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user