Skip to content

Commit 9e95e69

Browse files
committed
fix: improve session saving logic during overtime in PomodoroTimer
1 parent 6f0eca0 commit 9e95e69

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/core/pomodoro-timer.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -986,13 +986,21 @@ export class PomodoroTimer {
986986
// OVERTIME: If in overtime and continuous sessions, save session and skip double-counting
987987
if (this.timeRemaining < 0 && this.allowContinuousSessions) {
988988
shouldSaveSession = true;
989-
this.sessionCompletedButNotSaved = false;
990-
991-
// Save overtime focus session to SessionManager as individual session
992-
// Only save if session lasted at least 1 minute
993-
if (this.currentMode === 'focus' && this.lastCompletedSessionTime > 3) {
994-
await this.saveCompletedFocusSession();
989+
990+
// During overtime, if session was completed but not saved, now save it with overtime included
991+
if (this.sessionCompletedButNotSaved && this.currentMode === 'focus') {
992+
// Calculate total time including overtime
993+
const now = Date.now();
994+
const totalElapsedTime = Math.floor((now - this.sessionStartTime) / 1000);
995+
this.lastCompletedSessionTime = totalElapsedTime;
996+
997+
// Only save if session lasted at least 1 minute
998+
if (this.lastCompletedSessionTime > 60) {
999+
await this.saveCompletedFocusSession();
1000+
}
9951001
}
1002+
1003+
this.sessionCompletedButNotSaved = false;
9961004

9971005
// Move to next mode as usual
9981006
if (this.currentMode === 'focus') {
@@ -1338,8 +1346,7 @@ export class PomodoroTimer {
13381346
// Mark session as completed but not saved yet (will be saved when user skips)
13391347
this.sessionCompletedButNotSaved = true;
13401348

1341-
// Save completed focus session to SessionManager immediately
1342-
await this.saveCompletedFocusSession();
1349+
// Don't save session immediately during overtime - wait for skip to include full duration
13431350
}
13441351

13451352
// For continuous sessions, don't save the session data here

src/utils/theme-loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class ThemeLoader {
3939
// that gets updated by the build process or manually maintained
4040

4141
// This could be enhanced to use a build-time script that generates this list
42-
const knownThemes = [
42+
const knownThemes = [
4343
'espresso.css',
4444
'pipboy.css',
4545
'pommodore64.css'

0 commit comments

Comments
 (0)