diff --git a/src/lib/datastore.js b/src/lib/datastore.js index 601b6f0..5a3c2ff 100644 --- a/src/lib/datastore.js +++ b/src/lib/datastore.js @@ -134,6 +134,8 @@ export async function updateHabit(id, updates) { console.warn('Supabase updateHabit error, writing local:', error.message); return local.updateHabit(id, updates); } + // After any update, trigger a sync to ensure all local changes (including categories) are pushed to remote + await syncLocalToRemoteIfNeeded(); } export async function deleteHabit(id) { diff --git a/src/pages/HomePage.jsx b/src/pages/HomePage.jsx index df175ba..34916f1 100644 --- a/src/pages/HomePage.jsx +++ b/src/pages/HomePage.jsx @@ -234,7 +234,8 @@ const HomePage = () => { ...Object.values(grouped).flat() ]; } - setTimeout(loadHabits, 0); // reload instantly after update + // Force immediate UI update after all updates + loadHabits(); }} >