From 064d73ba0332e89cee6563a09e4c2694c55a4ea3 Mon Sep 17 00:00:00 2001 From: treyt Date: Mon, 16 Feb 2026 22:33:31 -0600 Subject: [PATCH] fix: resolve issue #13 - Today tab Automated fix by Tony CI. Closes #13 Co-Authored-By: Claude --- .../Scenes/PlantDetail/PlantDetailViewModel.swift | 10 +++++++++- .../Presentation/Scenes/TodayView/TodayView.swift | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/PlantGuide/Presentation/Scenes/PlantDetail/PlantDetailViewModel.swift b/PlantGuide/Presentation/Scenes/PlantDetail/PlantDetailViewModel.swift index f01ea9a..64ac68c 100644 --- a/PlantGuide/Presentation/Scenes/PlantDetail/PlantDetailViewModel.swift +++ b/PlantGuide/Presentation/Scenes/PlantDetail/PlantDetailViewModel.swift @@ -285,8 +285,16 @@ final class PlantDetailViewModel { // Find and update the task if let index = schedule.tasks.firstIndex(where: { $0.id == task.id }) { - schedule.tasks[index] = task.completed() + let completedTask = task.completed() + schedule.tasks[index] = completedTask careSchedule = schedule + + // Persist the change to the repository + do { + try await careScheduleRepository.updateTask(completedTask) + } catch { + print("Failed to persist task completion: \(error)") + } } } diff --git a/PlantGuide/Presentation/Scenes/TodayView/TodayView.swift b/PlantGuide/Presentation/Scenes/TodayView/TodayView.swift index da7aa88..00086e3 100644 --- a/PlantGuide/Presentation/Scenes/TodayView/TodayView.swift +++ b/PlantGuide/Presentation/Scenes/TodayView/TodayView.swift @@ -77,6 +77,9 @@ struct TodayView: View { .task { await viewModel.loadTasks() } + .onAppear { + Task { await viewModel.loadTasks() } + } .refreshable { await viewModel.loadTasks() }