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

Function applyPrePopulatedValues

src/modals/taskCreationFormState.ts:111–146  ·  view source on GitHub ↗
(
	state: TaskCreationFormState,
	values: TaskCreationPrepopulatedValues,
	taskTag: string
)

Source from the content-addressed store, hash-verified

109}
110
111function applyPrePopulatedValues(
112 state: TaskCreationFormState,
113 values: TaskCreationPrepopulatedValues,
114 taskTag: string
115): void {
116 if (values.title !== undefined) state.title = values.title;
117 if (values.due !== undefined) state.dueDate = values.due;
118 if (values.scheduled !== undefined) state.scheduledDate = values.scheduled;
119 if (values.priority !== undefined) state.priority = values.priority;
120 if (values.status !== undefined) state.status = values.status;
121 if (values.contexts !== undefined) {
122 state.contexts = values.contexts.join(", ");
123 }
124 if (values.projects !== undefined) {
125 state.projectStrings = values.projects.filter(
126 (project) => project && typeof project === "string" && project.trim() !== ""
127 );
128 }
129 if (values.tags !== undefined) {
130 state.tags = sanitizeTags(
131 values.tags.filter((tag) => tag !== taskTag).join(", ")
132 );
133 }
134 if (values.timeEstimate !== undefined) state.timeEstimate = values.timeEstimate;
135 if (values.recurrence !== undefined && typeof values.recurrence === "string") {
136 state.recurrenceRule = values.recurrence;
137 }
138 if (values.recurrence_anchor !== undefined) {
139 state.recurrenceAnchor = values.recurrence_anchor;
140 }
141 if (values.customFrontmatter) {
142 for (const [fieldKey, fieldValue] of Object.entries(values.customFrontmatter)) {
143 state.userFields[fieldKey] = fieldValue;
144 }
145 }
146}

Callers 1

Calls 1

sanitizeTagsFunction · 0.90

Tested by

no test coverage detected