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

1 Commits

Author SHA1 Message Date
Trey t
c1c824f288 fix: completed care tasks reappearing as overdue after reopening
When a user marked a care task as complete, the task would disappear
from the upcoming tasks section. However, upon navigating away and
returning to the plant detail, the task would reappear as incomplete
and overdue.

The root cause was that PlantDetailView only used .task to load
schedule data, which runs once on first appearance. When the view was
recreated (e.g., after navigating back from the collection list), the
Core Data fetch could return stale data due to context isolation in
NSPersistentCloudKitContainer.

Added .onAppear to reload the care schedule from Core Data every time
the view appears, matching the pattern already used in TodayView.
Also exposed a refreshSchedule() method on the ViewModel for this
purpose.

Fixes #2

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 10:13:08 -05:00