()
| 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 |
no test coverage detected