Major update for stability

This commit is contained in:
Mark Gregory
2026-09-08 15:22:19 +01:00
parent 3b95f53a25
commit b2f3c5aef6
24 changed files with 1059 additions and 212 deletions
+16 -2
View File
@@ -9,6 +9,7 @@ struct JobListView: View {
@Binding var showingNewJob: Bool
@State private var searchText = ""
@State private var filter: JobFilter = .all
@State private var persistenceError: String?
var body: some View {
VStack(spacing: 0) {
@@ -50,6 +51,14 @@ struct JobListView: View {
.listStyle(.sidebar)
}
}
.alert("Database Error", isPresented: Binding(
get: { persistenceError != nil },
set: { if !$0 { persistenceError = nil } }
)) {
Button("OK", role: .cancel) { persistenceError = nil }
} message: {
Text(persistenceError ?? "Unable to save job changes.")
}
}
private var dashboardHeader: some View {
@@ -198,6 +207,7 @@ struct JobListView: View {
copy.watchEnabled = job.watchEnabled
copy.watchPath = job.watchPath
copy.watchDebounceSeconds = job.watchDebounceSeconds
copy.allowUnattendedDelete = job.allowUnattendedDelete
modelContext.insert(copy)
saveAndRefresh()
selection = copy
@@ -210,8 +220,12 @@ struct JobListView: View {
}
private func saveAndRefresh() {
try? modelContext.save()
NotificationCenter.default.post(name: .syncJobsChanged, object: nil)
do {
try modelContext.save()
NotificationCenter.default.post(name: .syncJobsChanged, object: nil)
} catch {
persistenceError = error.localizedDescription
}
}
}