(payload: TaskUpdatedEventPayload)
| 2718 | } |
| 2719 | |
| 2720 | private normalizeUpdatedEvent(payload: TaskUpdatedEventPayload): TaskNotesApiEventPayload[] { |
| 2721 | const before = payload.originalTask ? copyTaskInfo(payload.originalTask) : undefined; |
| 2722 | const after = payload.updatedTask ? copyTaskInfo(payload.updatedTask) : undefined; |
| 2723 | const taskPath = after?.path ?? before?.path ?? payload.path ?? ""; |
| 2724 | const changes = buildTaskChanges(before, after); |
| 2725 | const context = this.getMutationContext(payload); |
| 2726 | const common = this.buildEventPayloadBase({ |
| 2727 | taskPath, |
| 2728 | before, |
| 2729 | after, |
| 2730 | task: after, |
| 2731 | changes, |
| 2732 | context, |
| 2733 | rawEvent: EVENT_TASK_UPDATED, |
| 2734 | }); |
| 2735 | |
| 2736 | const events: TaskNotesApiEventPayload[] = []; |
| 2737 | |
| 2738 | if (!before && after) { |
| 2739 | events.push({ ...common, event: "task.created" }); |
| 2740 | } |
| 2741 | |
| 2742 | events.push({ ...common, event: "task.updated" }); |
| 2743 | |
| 2744 | if (before && after && before.path !== after.path) { |
| 2745 | events.push({ ...common, event: "task.moved" }); |
| 2746 | } |
| 2747 | |
| 2748 | if (before && after && before.status !== after.status) { |
| 2749 | events.push({ ...common, event: "task.status.changed" }); |
| 2750 | |
| 2751 | const wasCompleted = this.plugin.statusManager.isCompletedStatus(before.status); |
| 2752 | const isCompleted = this.plugin.statusManager.isCompletedStatus(after.status); |
| 2753 | if (!wasCompleted && isCompleted) { |
| 2754 | events.push({ ...common, event: "task.completed" }); |
| 2755 | } else if (wasCompleted && !isCompleted) { |
| 2756 | events.push({ ...common, event: "task.uncompleted" }); |
| 2757 | } |
| 2758 | } |
| 2759 | |
| 2760 | if (before && after && before.archived !== after.archived) { |
| 2761 | events.push({ |
| 2762 | ...common, |
| 2763 | event: after.archived ? "task.archived" : "task.unarchived", |
| 2764 | }); |
| 2765 | } |
| 2766 | |
| 2767 | if (before && after && before.scheduled !== after.scheduled) { |
| 2768 | events.push({ ...common, event: "task.scheduled.changed" }); |
| 2769 | } |
| 2770 | |
| 2771 | if (before && after && before.due !== after.due) { |
| 2772 | events.push({ ...common, event: "task.due.changed" }); |
| 2773 | } |
| 2774 | |
| 2775 | if (before && after && before.priority !== after.priority) { |
| 2776 | events.push({ ...common, event: "task.priority.changed" }); |
| 2777 | } |
no test coverage detected