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

Method handleSave

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

Source from the content-addressed store, hash-verified

443 }
444
445 async handleSave(): Promise<void> {
446 if (!this.validateForm()) {
447 new Notice(this.t("modals.taskEdit.notices.titleRequired"));
448 return;
449 }
450
451 try {
452 const changes = this.getChanges({ includeConversionWrite: true });
453 const hasBlockingChanges =
454 this.pendingBlockingUpdates.added.length > 0 ||
455 this.pendingBlockingUpdates.removed.length > 0;
456 const hasTaskChanges = Object.keys(changes).length > 0;
457 const hasSubtaskChanges = this.hasSubtaskChanges();
458
459 if (this.unresolvedBlockingEntries.length > 0 && !hasBlockingChanges) {
460 new Notice(
461 this.t("modals.taskEdit.notices.blockingUnresolved", {
462 entries: this.unresolvedBlockingEntries.join(", "),
463 })
464 );
465 this.unresolvedBlockingEntries = [];
466 }
467
468 if (!hasTaskChanges && !hasBlockingChanges && !hasSubtaskChanges) {
469 new Notice(this.t("modals.taskEdit.notices.noChanges"));
470 this.close();
471 return;
472 }
473
474 let updatedTask = this.task;
475
476 if (hasTaskChanges) {
477 updatedTask = await this.plugin.taskService.updateTask(this.task, changes);
478 this.task = updatedTask;
479 if (Object.prototype.hasOwnProperty.call(changes, "details")) {
480 const updatedDetails = stringifyUnknown(
481 (changes as Record<string, unknown>).details
482 );
483 this.details = updatedDetails;
484 this.originalDetails = updatedDetails;
485 }
486 }
487
488 if (hasBlockingChanges) {
489 await this.plugin.taskService.updateBlockingRelationships(
490 updatedTask,
491 this.pendingBlockingUpdates.added,
492 this.pendingBlockingUpdates.removed,
493 this.pendingBlockingUpdates.raw
494 );
495
496 const refreshed = await this.plugin.cacheManager.getTaskInfo(updatedTask.path);
497 if (refreshed) {
498 updatedTask = refreshed;
499 this.task = refreshed;
500 }
501 }
502

Callers 5

openEditModalMethod · 0.95
createActionButtonsMethod · 0.95
handleSubmitShortcutFunction · 0.45
createActionButtonsFunction · 0.45

Calls 11

getChangesMethod · 0.95
hasSubtaskChangesMethod · 0.95
closeMethod · 0.95
applySubtaskChangesMethod · 0.95
stringifyUnknownFunction · 0.90
errorMethod · 0.80
updateTaskMethod · 0.65
getTaskInfoMethod · 0.65
validateFormMethod · 0.45
tMethod · 0.45

Tested by

no test coverage detected