diff --git a/mast-react-vite/src/App.tsx b/mast-react-vite/src/App.tsx index 64a8dc4..025b5b1 100644 --- a/mast-react-vite/src/App.tsx +++ b/mast-react-vite/src/App.tsx @@ -255,6 +255,28 @@ function App({ ctx, syncWorker, dbname, roomId }) { } }; + // Callback to toggle task priority + const handleTogglePriority = (taskId: number) => { + const sqlQuery = ` + UPDATE todos + SET priority = CASE + WHEN priority = 1 THEN 0 + ELSE 1 + END + WHERE id = ? + `; + + ctx.db.exec(sqlQuery, [taskId]); + + // Trigger sync with small delay to ensure changes are committed + setTimeout(() => { + syncWorker.postMessage({ + type: 'SYNC_CHANGES', + dbname + }); + }, 100); + }; + // Use previewTodos if available, otherwise use regular todos const displayTodos = previewTodos.length > 0 ? previewTodos : todos; @@ -476,7 +498,7 @@ function App({ ctx, syncWorker, dbname, roomId }) { />