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

Method refreshTaskData

src/modals/TaskEditModal.ts:178–240  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

176 }
177
178 private async refreshTaskData(): Promise<void> {
179 try {
180 const file = this.app.vault.getAbstractFileByPath(this.task.path);
181 if (!file || !(file instanceof TFile)) {
182 tasknotesLogger.warn("Could not find file for task:", {
183 category: "stale-data",
184 operation: "find-file-task",
185 details: { value: this.task.path },
186 });
187 return;
188 }
189
190 const content = await this.app.vault.read(file);
191 this.details = this.extractDetailsFromContent(content);
192 this.originalDetails = this.details;
193
194 // Check if this file is actually a task (has task tag/property)
195 // If not, keep the original task data (e.g., for "convert note to task" flow)
196 const metadata = this.app.metadataCache.getFileCache(file);
197 const isRecognizedTask =
198 metadata?.frontmatter && this.plugin.cacheManager.isTaskFile(metadata.frontmatter);
199
200 if (!isRecognizedTask) {
201 // File is not yet a task - keep the original task data passed to constructor
202 // This preserves user's default settings for status/priority during conversion
203 this.isConvertingNoteToTask = true;
204 this.task.details = this.details;
205 return;
206 }
207
208 this.isConvertingNoteToTask = false;
209
210 const cachedTaskInfo = await this.plugin.cacheManager.getTaskInfo(this.task.path);
211
212 if (cachedTaskInfo) {
213 cachedTaskInfo.details = this.details;
214 this.task = cachedTaskInfo;
215 this.options.task = cachedTaskInfo;
216 } else {
217 const freshTaskInfo = extractTaskInfo(
218 this.app,
219 content,
220 this.task.path,
221 file,
222 this.plugin.fieldMapper,
223 this.plugin.settings.storeTitleInFilename,
224 this.plugin.settings.defaultTaskStatus
225 );
226
227 if (freshTaskInfo) {
228 freshTaskInfo.details = this.details;
229 this.task = freshTaskInfo;
230 this.options.task = freshTaskInfo;
231 }
232 }
233 } catch (error) {
234 tasknotesLogger.warn("Could not refresh task data:", {
235 category: "stale-data",

Callers 1

openEditModalMethod · 0.95

Calls 7

extractTaskInfoFunction · 0.90
getAbstractFileByPathMethod · 0.80
warnMethod · 0.80
getFileCacheMethod · 0.80
isTaskFileMethod · 0.80
getTaskInfoMethod · 0.65
readMethod · 0.45

Tested by

no test coverage detected