Fixed a issue where stop did not reset the timer

This commit is contained in:
2025-12-17 21:27:08 +01:00
parent 2e7d4b8ee9
commit 27522aef1b
2 changed files with 11 additions and 1 deletions

10
main.ts
View File

@@ -132,6 +132,16 @@ export default class TaskWeaverPlugin extends Plugin {
await this.saveSettings(); await this.saveSettings();
} }
async stopTaskTimer(taskId: string): Promise<void> {
const task = this.settings.tasks.find(t => t.id === taskId);
if (!task) return;
task.startTime = null;
task.totalElapsed = 0;
await this.saveSettings();
}
async toggleTaskComplete(taskId: string): Promise<void> { async toggleTaskComplete(taskId: string): Promise<void> {
const task = this.settings.tasks.find(t => t.id === taskId); const task = this.settings.tasks.find(t => t.id === taskId);
if (!task) return; if (!task) return;

View File

@@ -127,7 +127,7 @@ export class TaskWeaverView extends ItemView {
cls: "taskweaver-timer-control-btn stop" cls: "taskweaver-timer-control-btn stop"
}); });
stopBtn.onclick = async () => { stopBtn.onclick = async () => {
await this.plugin.toggleTaskTimer(task.id); await this.plugin.stopTaskTimer(task.id);
}; };
const completeBtn = timerControls.createEl("button", { const completeBtn = timerControls.createEl("button", {