Fixed a issue where stop did not reset the timer
This commit is contained in:
10
main.ts
10
main.ts
@@ -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;
|
||||||
|
|||||||
2
view.ts
2
view.ts
@@ -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", {
|
||||||
|
|||||||
Reference in New Issue
Block a user