( plugin: TaskNotesPlugin, task: TaskInfo, description?: string )
| 10 | } |
| 11 | |
| 12 | export async function startTimeTrackingForTask( |
| 13 | plugin: TaskNotesPlugin, |
| 14 | task: TaskInfo, |
| 15 | description?: string |
| 16 | ): Promise<TaskInfo> { |
| 17 | let updatedTask = await plugin.taskService.startTimeTracking(task); |
| 18 | |
| 19 | const trimmedDescription = description?.trim(); |
| 20 | if (trimmedDescription && updatedTask.timeEntries && updatedTask.timeEntries.length > 0) { |
| 21 | const latestEntry = updatedTask.timeEntries[updatedTask.timeEntries.length - 1]; |
| 22 | if (latestEntry && !latestEntry.endTime) { |
| 23 | latestEntry.description = trimmedDescription; |
| 24 | updatedTask = await plugin.taskService.updateTask(updatedTask, { |
| 25 | timeEntries: updatedTask.timeEntries, |
| 26 | }); |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | return updatedTask; |
| 31 | } |
| 32 | |
| 33 | export async function resolveTaskForStopTimeTracking( |
| 34 | plugin: TaskNotesPlugin, |
no test coverage detected