MCPcopy Index your code
hub / github.com/callumalpass/tasknotes / buildTaskEditChanges

Function buildTaskEditChanges

src/modals/taskEditChanges.ts:86–208  ·  view source on GitHub ↗
(input: TaskEditChangeInput)

Source from the content-addressed store, hash-verified

84}
85
86export function buildTaskEditChanges(input: TaskEditChangeInput): TaskEditChangeResult {
87 const changes: Partial<TaskInfo> = {};
88
89 if (input.title.trim() !== input.task.title) {
90 changes.title = input.title.trim();
91 }
92
93 if (input.dueDate !== (input.task.due || "")) {
94 changes.due = input.dueDate || undefined;
95 }
96
97 if (input.scheduledDate !== (input.task.scheduled || "")) {
98 changes.scheduled = input.scheduledDate || undefined;
99 }
100
101 if (input.priority !== input.task.priority) {
102 changes.priority = input.priority;
103 }
104
105 if (input.status !== input.task.status) {
106 changes.status = input.status;
107 }
108
109 const newContexts = input.contexts
110 .split(",")
111 .map((context) => context.trim())
112 .filter((context) => context.length > 0);
113 const oldContexts = input.task.contexts || [];
114
115 if (JSON.stringify(newContexts.sort()) !== JSON.stringify(oldContexts.sort())) {
116 changes.contexts = newContexts.length > 0 ? newContexts : undefined;
117 }
118
119 const newProjects = splitListPreservingLinksAndQuotes(input.projects);
120 const oldProjects = input.task.projects || [];
121 const normalizedNewProjects = normalizeProjectList(newProjects).sort();
122 const normalizedOldProjects = normalizeProjectList(oldProjects).sort();
123
124 if (
125 JSON.stringify(normalizedNewProjects) !== JSON.stringify(normalizedOldProjects)
126 ) {
127 changes.projects = newProjects.length > 0 ? newProjects : [];
128 }
129
130 const tagsUnchanged = sanitizeTags(input.tags) === sanitizeTags(input.initialTags);
131 let newTags = input.tags
132 .split(",")
133 .map((tag) => tag.trim())
134 .filter((tag) => tag.length > 0);
135
136 if (input.taskIdentificationMethod === "tag" && input.taskTag) {
137 newTags = appendMissingTaskIdentificationTags(
138 newTags,
139 input.task.tags || [],
140 input.taskTag,
141 input.hideIdentifyingTagsMode
142 );
143 }

Calls 9

sanitizeTagsFunction · 0.90
getUserFieldChangesFunction · 0.90
getCurrentTimestampFunction · 0.90
normalizeProjectListFunction · 0.85
dependenciesEqualFunction · 0.85
buildBlockingUpdatesFunction · 0.85

Tested by

no test coverage detected