Skip to content

Commit

Permalink
fix(tasks): fix totalEst calculation only taking uncompleted tasks in…
Browse files Browse the repository at this point in the history
…to account

The totalEst calculation previously included completed tasks, which was incorrect. This commit fixes the issue by only taking uncompleted tasks into account.
  • Loading branch information
tfkhdyt committed Apr 18, 2024
1 parent 64e9505 commit 429cadc
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"package": {
"productName": "Pomodoro",
"version": "0.7.2"
"version": "0.7.3"
},
"tauri": {
"allowlist": {
Expand Down
66 changes: 35 additions & 31 deletions src/components/task/Tasks.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -76,37 +78,39 @@
config={data.config} />
{/each}
</div>
<div
class={cn(
'flex space-x-6 items-baseline justify-center rounded-md px-2 py-6 text-center border-t border-white rounded-t-none',
match(data.appData.pomodoroState)
.with('pomodoro', () => 'bg-[#c15c5c]')
.with('short-break', () => 'bg-[#4c9196]')
.with('long-break', () => 'bg-[#4d7fa2]')
.exhaustive()
)}>
<div class="text-white/75 font-medium">
Pomos:
<span class="text-white text-2xl font-semibold ml-1">{totalAct}</span>
<span>/</span>
<span class="text-white text-2xl font-semibold">
{match(totalAct > totalEst)
.with(true, () => totalAct)
.otherwise(() => totalEst)}
</span>
</div>
<div class="text-white/75 font-medium">
Finish At:
<span class="text-white text-2xl font-semibold ml-1">
{format(add(new Date(), { minutes: finishAtMinute }), 'HH:mm')}
</span>
<span class="ml-1">
({formatDistanceToNowStrict(
add(new Date(), { minutes: finishAtMinute })
)})
</span>
{#if totalEst > 0}
<div
class={cn(
'flex space-x-6 items-baseline justify-center rounded-md px-2 py-6 text-center border-t border-white rounded-t-none',
match(data.appData.pomodoroState)
.with('pomodoro', () => 'bg-[#c15c5c]')
.with('short-break', () => 'bg-[#4c9196]')
.with('long-break', () => 'bg-[#4d7fa2]')
.exhaustive()
)}>
<div class="text-white/75 font-medium">
Pomos:
<span class="text-white text-2xl font-semibold ml-1">{totalAct}</span>
<span>/</span>
<span class="text-white text-2xl font-semibold">
{match(totalAct > totalEst)
.with(true, () => totalAct)
.otherwise(() => totalEst)}
</span>
</div>
<div class="text-white/75 font-medium">
Finish At:
<span class="text-white text-2xl font-semibold ml-1">
{format(add(new Date(), { minutes: finishAtMinute }), 'HH:mm')}
</span>
<span class="ml-1">
({formatDistanceToNowStrict(
add(new Date(), { minutes: finishAtMinute })
)})
</span>
</div>
</div>
</div>
{/if}
{/if}
</section>
<EditTask appData={data.appData} {save} />

0 comments on commit 429cadc

Please sign in to comment.