MCPcopy
hub / github.com/callumalpass/tasknotes / handleFileChanged

Method handleFileChanged

src/utils/TaskManager.ts:166–202  ·  view source on GitHub ↗

* Handle file change - emit events for listeners

(file: TFile, cache: unknown)

Source from the content-addressed store, hash-verified

164 * Handle file change - emit events for listeners
165 */
166 private async handleFileChanged(file: TFile, cache: unknown): Promise<void> {
167 let updatedTask: TaskInfo | null = null;
168 let filterIndexChanged = false;
169
170 if (cache && typeof cache === "object" && "frontmatter" in cache) {
171 const frontmatter = (cache as { frontmatter?: unknown }).frontmatter;
172 if (frontmatter && this.isTaskFile(frontmatter)) {
173 const metadataTaskInfo = this.extractTaskInfoFromNative(file.path, frontmatter);
174 const pendingTaskInfo = this.getPendingTaskInfo(file.path);
175 if (
176 pendingTaskInfo &&
177 this.shouldUsePendingTaskInfo(pendingTaskInfo, metadataTaskInfo)
178 ) {
179 updatedTask = pendingTaskInfo;
180 } else {
181 this.pendingTaskInfoByPath.delete(file.path);
182 updatedTask = metadataTaskInfo;
183 }
184 } else {
185 this.pendingTaskInfoByPath.delete(file.path);
186 }
187 }
188 filterIndexChanged = this.updateFilterIndexesForFile(file.path, cache);
189
190 // Emit both the generic file event and the task-specific event so rendered task cards
191 // refresh when users edit task frontmatter directly in Obsidian.
192 this.trigger("file-updated", { path: file.path, file, updatedTask, filterIndexChanged });
193 if (updatedTask) {
194 this.trigger(EVENT_TASK_UPDATED, {
195 path: file.path,
196 task: updatedTask,
197 taskInfo: updatedTask,
198 updatedTask,
199 });
200 }
201 this.trigger("data-changed");
202 }
203
204 /**
205 * Handle file deletion

Calls 7

isTaskFileMethod · 0.95
getPendingTaskInfoMethod · 0.95
deleteMethod · 0.65
triggerMethod · 0.65

Tested by

no test coverage detected