fix: completed tasks reappearing as overdue (#2) #4

Merged
admin merged 1 commits from fix/issue-2-task-completion-persistence into master 2026-04-12 10:14:26 -05:00
2 changed files with 14 additions and 0 deletions

View File

@@ -116,6 +116,14 @@ struct PlantDetailView: View {
.task { .task {
await viewModel.loadCareInfo() await viewModel.loadCareInfo()
} }
.onAppear {
// Reload schedule from Core Data every time the view appears.
// .task only runs on first appearance; this ensures task completion
// states are always current when navigating back to this view.
Task {
await viewModel.refreshSchedule()
}
}
.refreshable { .refreshable {
await viewModel.refresh() await viewModel.refresh()
} }

View File

@@ -144,6 +144,12 @@ final class PlantDetailViewModel {
isLoading = false isLoading = false
} }
/// Reloads the care schedule from the repository.
/// Call on view reappearance to pick up persisted task completions.
func refreshSchedule() async {
await loadExistingSchedule()
}
/// Loads an existing care schedule from the repository /// Loads an existing care schedule from the repository
private func loadExistingSchedule() async { private func loadExistingSchedule() async {
do { do {