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

Method getTaskInfo

src/utils/TaskManager.ts:259–289  ·  view source on GitHub ↗

* Get task info for a specific file path (just-in-time)

(path: string)

Source from the content-addressed store, hash-verified

257 * Get task info for a specific file path (just-in-time)
258 */
259 async getTaskInfo(path: string): Promise<TaskInfo | null> {
260 if (!this.isValidFile(path)) return null;
261
262 const file = this.app.vault.getAbstractFileByPath(path);
263 if (!(file instanceof TFile)) return null;
264
265 const pendingTaskInfo = this.getPendingTaskInfo(path);
266 const metadata = this.app.metadataCache.getFileCache(file);
267 if (!metadata?.frontmatter) {
268 if (pendingTaskInfo) {
269 return pendingTaskInfo;
270 }
271
272 const frontmatter = await this.readFrontmatterFromFile(file);
273 if (!frontmatter || !this.isTaskFile(frontmatter)) return null;
274
275 return this.extractTaskInfoFromNative(path, frontmatter);
276 }
277
278 const metadataTaskInfo = this.isTaskFile(metadata.frontmatter)
279 ? this.extractTaskInfoFromNative(path, metadata.frontmatter)
280 : null;
281
282 if (pendingTaskInfo && this.shouldUsePendingTaskInfo(pendingTaskInfo, metadataTaskInfo)) {
283 return pendingTaskInfo;
284 }
285
286 this.pendingTaskInfoByPath.delete(path);
287
288 return metadataTaskInfo;
289 }
290
291 private getPendingTaskInfo(path: string): TaskInfo | null {
292 const taskInfo = this.pendingTaskInfoByPath.get(path);

Callers 4

getAllTasksMethod · 0.95
getTaskByPathMethod · 0.95
getCachedTaskInfoMethod · 0.95
getTaskInfoForDateMethod · 0.95

Calls 9

isValidFileMethod · 0.95
getPendingTaskInfoMethod · 0.95
isTaskFileMethod · 0.95
getAbstractFileByPathMethod · 0.80
getFileCacheMethod · 0.80
deleteMethod · 0.65

Tested by

no test coverage detected