Restart service when settings change

This commit is contained in:
世界
2025-12-07 10:28:51 +08:00
parent bd5e5f3a79
commit 39338ab133
10 changed files with 77 additions and 22 deletions
@@ -243,7 +243,7 @@ import SwiftUI
@ToolbarContentBuilder private var toolbar: some ToolbarContent {
#if os(tvOS)
ToolbarItemGroup(placement: .topBarLeading) {
ToolbarItemGroup(placement: .topBarLeading) {
navigationButtons
}
#endif
@@ -143,7 +143,7 @@ import SwiftUI
}
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
TVToolbarButton(title: String(localized: "Reset")) {
TVToolbarButton(title: String(localized: "Reset")) {
Task {
await configuration.resetToDefault()
}
@@ -139,7 +139,7 @@ struct ProfilePickerSheet: View {
.environment(\.editMode, $editMode)
.toolbar {
ToolbarItem(placement: .confirmationAction) {
TVToolbarButton(title: editMode.isEditing ? String(localized: "Done"): String(localized: "Edit")) {
TVToolbarButton(title: editMode.isEditing ? String(localized: "Done") : String(localized: "Edit")) {
withAnimation {
if editMode.isEditing {
movingProfileID = nil
@@ -32,17 +32,7 @@ public final class OverviewViewModel: BaseViewModel {
try LibboxNewStandaloneCommandClient()!.setSystemProxyEnabled(enabled)
} else {
await MainActor.run { reasserting = true }
try await profile.stop()
var waitSeconds = 0
while await profile.status != .disconnected {
try await Task.sleep(nanoseconds: NSEC_PER_SEC)
waitSeconds += 1
if waitSeconds >= 5 {
throw NSError(domain: "Restart service timeout", code: 0)
}
}
try await profile.start()
try await profile.restart()
await MainActor.run { reasserting = false }
}
} catch {