( context: ApplyTaskEditSubtaskChangesContext<TSubtask, TParent>, subtaskFile: TSubtask )
| 128 | } |
| 129 | |
| 130 | async function addTaskEditSubtaskRelation< |
| 131 | TSubtask extends TaskEditSubtaskPathLike, |
| 132 | TParent extends TaskEditSubtaskParentLike, |
| 133 | >( |
| 134 | context: ApplyTaskEditSubtaskChangesContext<TSubtask, TParent>, |
| 135 | subtaskFile: TSubtask |
| 136 | ): Promise<boolean> { |
| 137 | const subtaskInfo = await context.getTaskInfo(subtaskFile.path); |
| 138 | if (!subtaskInfo) { |
| 139 | return false; |
| 140 | } |
| 141 | |
| 142 | const projectReference = context.buildProjectReference( |
| 143 | context.parentTaskFile, |
| 144 | subtaskFile.path |
| 145 | ); |
| 146 | const legacyReference = `[[${context.parentTaskFile.basename}]]`; |
| 147 | const updatedProjects = getSubtaskProjectAssignmentUpdate( |
| 148 | subtaskInfo.projects, |
| 149 | projectReference, |
| 150 | legacyReference |
| 151 | ); |
| 152 | |
| 153 | if (!updatedProjects) { |
| 154 | return false; |
| 155 | } |
| 156 | |
| 157 | await context.updateTaskProjects(subtaskInfo, updatedProjects); |
| 158 | return true; |
| 159 | } |
| 160 | |
| 161 | async function removeTaskEditSubtaskRelation< |
| 162 | TSubtask extends TaskEditSubtaskPathLike, |
no test coverage detected