( path: string, options?: StartTimeEntryOptions, context?: TaskNotesMutationContext )
| 2187 | } |
| 2188 | |
| 2189 | private async startTime( |
| 2190 | path: string, |
| 2191 | options?: StartTimeEntryOptions, |
| 2192 | context?: TaskNotesMutationContext |
| 2193 | ): Promise<TaskInfo> { |
| 2194 | const task = await this.requireTask(path); |
| 2195 | let updatedTask = await this.withMutationContext([task.path], context, () => |
| 2196 | this.plugin.taskService.startTimeTracking(task) |
| 2197 | ); |
| 2198 | |
| 2199 | if (options?.description && updatedTask.timeEntries?.length) { |
| 2200 | const timeEntries = updatedTask.timeEntries.map((entry) => ({ ...entry })); |
| 2201 | let activeEntryIndex = -1; |
| 2202 | for (let index = timeEntries.length - 1; index >= 0; index--) { |
| 2203 | if (!timeEntries[index].endTime) { |
| 2204 | activeEntryIndex = index; |
| 2205 | break; |
| 2206 | } |
| 2207 | } |
| 2208 | if (activeEntryIndex >= 0) { |
| 2209 | timeEntries[activeEntryIndex] = { |
| 2210 | ...timeEntries[activeEntryIndex], |
| 2211 | description: options.description, |
| 2212 | }; |
| 2213 | updatedTask = await this.updateTask(updatedTask.path, { timeEntries }, context); |
| 2214 | } |
| 2215 | } |
| 2216 | |
| 2217 | return copyTaskInfo(updatedTask); |
| 2218 | } |
| 2219 | |
| 2220 | private async stopTime(path: string, context?: TaskNotesMutationContext): Promise<TaskInfo> { |
| 2221 | const task = await this.requireTask(path); |
no test coverage detected