Merge pull request #107 from kkebo/realtime-status-update

This commit is contained in:
Kenta Kubo 2025-05-08 00:14:01 +09:00 committed by GitHub
commit d2502718db
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -197,10 +197,16 @@ extension ContentView: View {
}
}
.onAppear(perform: self.updateStatus)
.onChange(of: self.scenePhase) { phase in
if phase == .active {
.task {
for await _ in NotificationCenter.default
.notifications(named: .NEDNSSettingsConfigurationDidChange)
.map(\.name)
{
self.updateStatus()
} else if phase == .background {
}
}
.onChange(of: self.scenePhase) { phase in
if phase == .background {
// FIXME: This is a workaround for self.$severs[i].
// That cannot save settings as soon as it is modified.
guard let id = self.usedID,
@ -274,10 +280,16 @@ extension ContentView: View {
}
}
.onAppear(perform: self.updateStatus)
.onChange(of: self.scenePhase) { phase in
if phase == .active {
.task {
for await _ in NotificationCenter.default
.notifications(named: .NEDNSSettingsConfigurationDidChange)
.map(\.name)
{
self.updateStatus()
} else if phase == .background {
}
}
.onChange(of: self.scenePhase) { phase in
if phase == .background {
// FIXME: This is a workaround for self.$severs[i].
// That cannot save settings as soon as it is modified.
guard let id = self.usedID,
@ -345,14 +357,6 @@ extension ContentView: View {
}
}
}
#if targetEnvironment(macCatalyst)
ToolbarItemGroup(placement: .bottomBar) {
Spacer()
Button(action: self.updateStatus) {
Label("Refresh", systemImage: "arrow.clockwise")
}
}
#endif
}
private func sidebarRow(at i: Int) -> some View {