fix: prefer id matching when deleting todos (Cubic feedback)
- When deleting tasks, prefer matching by id if present - Fall back to content matching only when todo has no id - Prevents deleting unrelated todos with same subject
This commit is contained in:
@@ -108,11 +108,16 @@ export async function syncTaskTodoUpdate(
|
||||
});
|
||||
const currentTodos = extractTodos(response);
|
||||
const taskTodo = syncTaskToTodo(task);
|
||||
const nextTodos = currentTodos.filter((todo) =>
|
||||
taskTodo
|
||||
? !todosMatch(todo, taskTodo)
|
||||
: todo.content !== task.subject
|
||||
);
|
||||
const nextTodos = currentTodos.filter((todo) => {
|
||||
if (taskTodo) {
|
||||
return !todosMatch(todo, taskTodo);
|
||||
}
|
||||
// Deleted task: match by id if present, otherwise by content
|
||||
if (todo.id) {
|
||||
return todo.id !== task.id;
|
||||
}
|
||||
return todo.content !== task.subject;
|
||||
});
|
||||
const todo = taskTodo;
|
||||
|
||||
if (todo) {
|
||||
|
||||
Reference in New Issue
Block a user