Skip to content

fix: prevent planned tasks deletion by stale closure in forceSyncToDatabase#157

Merged
AdamJ merged 1 commit into
mainfrom
claude/tasks-deletion-supabase-Jln2Q
May 31, 2026
Merged

fix: prevent planned tasks deletion by stale closure in forceSyncToDatabase#157
AdamJ merged 1 commit into
mainfrom
claude/tasks-deletion-supabase-Jln2Q

Conversation

@AdamJ
Copy link
Copy Markdown
Owner

@AdamJ AdamJ commented May 31, 2026

forceSyncToDatabase was closing over the React state value plannedTasks
(initially []) rather than plannedTasksRef.current. If the function fired
before the initial Supabase load completed (e.g. online event, manual sync
button, category/project save in another component), it called
savePlannedTasks([]) which hit the delete-all branch and wiped the table.

Mirrors the projectsRef fix from #154: update plannedTasksRef.current
synchronously in loadData and in every mutation (addPlannedTask,
updatePlannedTask, deletePlannedTask, movePlannedTask, pullPlannedTaskToDay),
use plannedTasksRef.current in forceSyncToDatabase, and drop plannedTasks
from its dependency array.

https://claude.ai/code/session_01CJG4Vxc5RpXbuF1NuWF4cG

…tabase

forceSyncToDatabase was closing over the React state value `plannedTasks`
(initially []) rather than `plannedTasksRef.current`. If the function fired
before the initial Supabase load completed (e.g. online event, manual sync
button, category/project save in another component), it called
savePlannedTasks([]) which hit the delete-all branch and wiped the table.

Mirrors the projectsRef fix from #154: update plannedTasksRef.current
synchronously in loadData and in every mutation (addPlannedTask,
updatePlannedTask, deletePlannedTask, movePlannedTask, pullPlannedTaskToDay),
use plannedTasksRef.current in forceSyncToDatabase, and drop plannedTasks
from its dependency array.

https://claude.ai/code/session_01CJG4Vxc5RpXbuF1NuWF4cG
@AdamJ AdamJ merged commit db7cd37 into main May 31, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants