From 429cadcc0db9b0bb3cc270cccf906603028ed46b Mon Sep 17 00:00:00 2001 From: tfkhdyt Date: Thu, 18 Apr 2024 10:43:06 +0700 Subject: [PATCH] fix(tasks): fix totalEst calculation only taking uncompleted tasks into account The totalEst calculation previously included completed tasks, which was incorrect. This commit fixes the issue by only taking uncompleted tasks into account. --- src-tauri/tauri.conf.json | 2 +- src/components/task/Tasks.svelte | 66 +++++++++++++++++--------------- 2 files changed, 36 insertions(+), 32 deletions(-) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 5378caf..32a012e 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -8,7 +8,7 @@ }, "package": { "productName": "Pomodoro", - "version": "0.7.2" + "version": "0.7.3" }, "tauri": { "allowlist": { diff --git a/src/components/task/Tasks.svelte b/src/components/task/Tasks.svelte index 1888b22..b29f1be 100644 --- a/src/components/task/Tasks.svelte +++ b/src/components/task/Tasks.svelte @@ -16,7 +16,9 @@ export let reps: number; $: totalAct = data.appData.tasks.reduce((a, b) => a + b.act, 0); - $: totalEst = data.appData.tasks.reduce((a, b) => a + b.est, 0); + $: totalEst = data.appData.tasks + .filter((t) => !t.done) + .reduce((a, b) => a + b.est, 0); $: finishAtMinute = (() => { let rep = reps; let result = 0; @@ -76,37 +78,39 @@ config={data.config} /> {/each} -
'bg-[#c15c5c]') - .with('short-break', () => 'bg-[#4c9196]') - .with('long-break', () => 'bg-[#4d7fa2]') - .exhaustive() - )}> -
- Pomos: - {totalAct} - / - - {match(totalAct > totalEst) - .with(true, () => totalAct) - .otherwise(() => totalEst)} - -
-
- Finish At: - - {format(add(new Date(), { minutes: finishAtMinute }), 'HH:mm')} - - - ({formatDistanceToNowStrict( - add(new Date(), { minutes: finishAtMinute }) - )}) - + {#if totalEst > 0} +
'bg-[#c15c5c]') + .with('short-break', () => 'bg-[#4c9196]') + .with('long-break', () => 'bg-[#4d7fa2]') + .exhaustive() + )}> +
+ Pomos: + {totalAct} + / + + {match(totalAct > totalEst) + .with(true, () => totalAct) + .otherwise(() => totalEst)} + +
+
+ Finish At: + + {format(add(new Date(), { minutes: finishAtMinute }), 'HH:mm')} + + + ({formatDistanceToNowStrict( + add(new Date(), { minutes: finishAtMinute }) + )}) + +
-
+ {/if} {/if}