fix(tasks): live updates only add real tasks, not fresh Quick Dump notes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2303ccce68
commit
052c7f2fbc
4 files changed
+21
-16
No files matched your search
@@ -48,6 +48,10 @@ const stopOnControl = (e: React.MouseEvent) => {
|
||||
if ((e.target as HTMLElement).closest('button, select, a, input')) e.stopPropagation();
|
||||
};
|
||||
|
||||
// Same rule as the server's task query: a fresh Quick Dump note (status inbox) is no task yet
|
||||
const isTaskThought = (t: Thought) =>
|
||||
t.status === 'kept' || (t.status === 'converted' && t.convertedType === 'task');
|
||||
|
||||
interface TasksViewProps {
|
||||
currentUser?: User | null;
|
||||
onRefreshStats: () => void;
|
||||
@@ -186,13 +190,7 @@ export const TasksView: React.FC<TasksViewProps> = ({
|
||||
|
||||
if (msg.event === 'TASK_CREATED') {
|
||||
const created = msg.payload as Thought;
|
||||
if (
|
||||
created &&
|
||||
(created.status === 'converted' ||
|
||||
created.kanbanStatus ||
|
||||
created.taskListId ||
|
||||
created.isCompleted !== undefined)
|
||||
) {
|
||||
if (created && isTaskThought(created)) {
|
||||
setTasks((prev) => {
|
||||
if (prev.some((t) => t.id === created.id)) return prev;
|
||||
if (selectedListIdRef.current !== 'all' && created.taskListId !== selectedListIdRef.current) return prev;
|
||||
@@ -207,17 +205,18 @@ export const TasksView: React.FC<TasksViewProps> = ({
|
||||
const exists = prev.some((t) => t.id === updated.id);
|
||||
if (!exists) {
|
||||
if (
|
||||
(updated.status === 'converted' ||
|
||||
updated.kanbanStatus ||
|
||||
updated.taskListId ||
|
||||
updated.isCompleted !== undefined) &&
|
||||
isTaskThought(updated) &&
|
||||
(selectedListIdRef.current === 'all' || updated.taskListId === selectedListIdRef.current)
|
||||
) {
|
||||
return [updated, ...prev];
|
||||
}
|
||||
return prev;
|
||||
}
|
||||
if (selectedListIdRef.current !== 'all' && updated.taskListId !== selectedListIdRef.current) {
|
||||
// Undone back into the Quick Dump, discarded, or moved to another list
|
||||
if (
|
||||
!isTaskThought(updated) ||
|
||||
(selectedListIdRef.current !== 'all' && updated.taskListId !== selectedListIdRef.current)
|
||||
) {
|
||||
return prev.filter((t) => t.id !== updated.id);
|
||||
}
|
||||
return prev.map((t) => (t.id === updated.id ? updated : t));
|
||||
|
||||
Reference in new issue
Block a user