Skip to content

Commit ba75a7d

Browse files
committed
fix pomodoro bug
1 parent 591f196 commit ba75a7d

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/components/PomodoroTimer.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@ const PomodoroTimer: React.FC<PomodoroTimerProps> = ({
205205
};
206206

207207
const handleResume = () => {
208+
if (pauseStart) {
209+
addSession(pauseStart, Date.now(), "break");
210+
}
208211
resume();
209212
setStartTime(Date.now());
210213
};
@@ -213,6 +216,9 @@ const PomodoroTimer: React.FC<PomodoroTimerProps> = ({
213216
// If we are currently working, save the work done so far
214217
if (mode === "work" && startTime) {
215218
addSession(startTime, Date.now(), "work");
219+
} else if (pauseStart) {
220+
// If we were paused, the gap was a break
221+
addSession(pauseStart, Date.now(), "break");
216222
}
217223
startBreak();
218224
// Store sets startTime in startBreak()
@@ -222,6 +228,8 @@ const PomodoroTimer: React.FC<PomodoroTimerProps> = ({
222228
// If we are currently in a break, save the break time taken so far
223229
if (mode === "break" && startTime) {
224230
addSession(startTime, Date.now(), "break");
231+
} else if (pauseStart) {
232+
addSession(pauseStart, Date.now(), "break");
225233
}
226234
skipBreak();
227235
// Store sets startTime in skipBreak()

0 commit comments

Comments
 (0)