Skip to content

Commit

Permalink
feat: a way to pause active task from tasks list (#56)
Browse files Browse the repository at this point in the history
This allows to pause / unpause task by using just spacebar

Co-authored-by: Simon Laux <[email protected]>
  • Loading branch information
WofWca and Simon-Laux authored May 25, 2024
1 parent 80e4c3a commit ab1e0e3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- feat: a way to pause active task from tasks list.
This allows to pause / unpause task by using just spacebar
- fix: going to "Statistics" crashing the app sometimes

## 0.8.0
Expand Down
23 changes: 18 additions & 5 deletions src/pages/TrackPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,22 @@ function QuickStartTask({
timeSpendRefreshTS: DateTime;
activeTask?: TaskEntry;
}) {
const create = () => {
startEntry(label);
};
let is_active = false;
if (activeTask?.label === label) {
is_active = true;
}
const createOrStop = () => {
if (is_active) {
if (!activeTask) {
console.error("Attempted to pause. `is_active`, but no `activeTask`?");
return;
}

endEntry(activeTask.id);
} else {
startEntry(label);
}
};

return (
<div className="flex p-2">
Expand All @@ -42,8 +51,12 @@ function QuickStartTask({
)}
</div>
<div className="flex-grow">{label}</div>
<button className="btn" onClick={create} disabled={is_active}>
<PlayIcon className="mr-0.5 w-5" />
<button className="btn" onClick={createOrStop}>
{is_active ? (
<StopIcon className="mr-0.5 w-5" />
) : (
<PlayIcon className="mr-0.5 w-5" />
)}
</button>
</div>
);
Expand Down

0 comments on commit ab1e0e3

Please sign in to comment.