(
currentTask: TaskInfo,
addedBlockedTaskPaths: string[],
removedBlockedTaskPaths: string[],
rawEntries: Record<string, TaskDependency | string> = {}
)
| 1461 | } |
| 1462 | |
| 1463 | async updateBlockingRelationships( |
| 1464 | currentTask: TaskInfo, |
| 1465 | addedBlockedTaskPaths: string[], |
| 1466 | removedBlockedTaskPaths: string[], |
| 1467 | rawEntries: Record<string, TaskDependency | string> = {} |
| 1468 | ): Promise<void> { |
| 1469 | // This method is called when the current task's "blocking" list is updated in the UI. |
| 1470 | // The current task is the one blocking other tasks. |
| 1471 | // We need to update the blockedBy field of the tasks that this task is blocking. |
| 1472 | |
| 1473 | const { uniqueAdditions, uniqueRemovals } = buildBlockingRelationshipPathChanges( |
| 1474 | addedBlockedTaskPaths, |
| 1475 | removedBlockedTaskPaths |
| 1476 | ); |
| 1477 | |
| 1478 | // Remove current task from the blockedBy field of tasks it's no longer blocking |
| 1479 | for (const blockedTaskPath of uniqueRemovals) { |
| 1480 | const blockedTask = await this.plugin.cacheManager.getTaskInfo(blockedTaskPath); |
| 1481 | if (!blockedTask) { |
| 1482 | continue; |
| 1483 | } |
| 1484 | |
| 1485 | const updates = buildBlockedByTaskUpdate( |
| 1486 | this.computeBlockedByUpdate(blockedTask, currentTask.path, "remove") |
| 1487 | ); |
| 1488 | if (!updates) { |
| 1489 | continue; |
| 1490 | } |
| 1491 | |
| 1492 | await this.updateTask(blockedTask, updates); |
| 1493 | } |
| 1494 | |
| 1495 | // Add current task to the blockedBy field of tasks it's now blocking |
| 1496 | for (const blockedTaskPath of uniqueAdditions) { |
| 1497 | const blockedTask = await this.plugin.cacheManager.getTaskInfo(blockedTaskPath); |
| 1498 | if (!blockedTask) { |
| 1499 | continue; |
| 1500 | } |
| 1501 | |
| 1502 | // Don't use the raw entry from the UI since it was created relative to the current task's path |
| 1503 | // Instead, always generate a new link from the blocked task's perspective |
| 1504 | const updates = buildBlockedByTaskUpdate( |
| 1505 | this.computeBlockedByUpdate( |
| 1506 | blockedTask, |
| 1507 | currentTask.path, |
| 1508 | "add", |
| 1509 | rawEntries[blockedTaskPath] |
| 1510 | ) |
| 1511 | ); |
| 1512 | if (!updates) { |
| 1513 | continue; |
| 1514 | } |
| 1515 | |
| 1516 | await this.updateTask(blockedTask, updates); |
| 1517 | } |
| 1518 | } |
| 1519 | |
| 1520 | private computeBlockedByUpdate( |
no test coverage detected