Made status able to mark tasks as incomplete after marking them as commplete
This commit is contained in:
+20
-2
@@ -1139,10 +1139,28 @@ export const updateTask = async (id: string, updates: Partial<Task>) => {
|
|||||||
|
|
||||||
// 0. Check for Hand-off Logic (Tag-based ownership transfer)
|
// 0. Check for Hand-off Logic (Tag-based ownership transfer)
|
||||||
const currentTask = store.tasks.find(t => t.id === id);
|
const currentTask = store.tasks.find(t => t.id === id);
|
||||||
let finalUpdates = updates;
|
let finalUpdates = { ...updates };
|
||||||
|
|
||||||
|
// Sync status and completed
|
||||||
|
if (finalUpdates.status !== undefined) {
|
||||||
|
finalUpdates.completed = finalUpdates.status === 10;
|
||||||
|
} else if (finalUpdates.completed !== undefined) {
|
||||||
|
// If only completed is passed, sync status
|
||||||
|
// But if both pass, status takes precedence (above)
|
||||||
|
// Wait, if I change completed to false, status should be 0? Or previous status?
|
||||||
|
// Let's assume toggleTask handles that. updateTask is lower level.
|
||||||
|
// But for safety:
|
||||||
|
if (finalUpdates.completed) {
|
||||||
|
finalUpdates.status = 10;
|
||||||
|
} else if (currentTask && currentTask.status === 10) {
|
||||||
|
// Uncompleting a completed task -> reset to 0
|
||||||
|
finalUpdates.status = 0;
|
||||||
|
}
|
||||||
|
// If uncompleting a non-completed task (weird), keep status?
|
||||||
|
}
|
||||||
|
|
||||||
if (currentTask) {
|
if (currentTask) {
|
||||||
finalUpdates = checkForHandoffs(currentTask, updates);
|
finalUpdates = checkForHandoffs(currentTask, finalUpdates);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Optimistic update with timestamp to prevent stale realtime events
|
// Optimistic update with timestamp to prevent stale realtime events
|
||||||
|
|||||||
Reference in New Issue
Block a user