Skip to content

Commit dfa320c

Browse files
committed
fix: prevent double-counting sessions during overtime and improve session saving logic
1 parent 5b8da41 commit dfa320c

File tree

2 files changed

+42
-27
lines changed

2 files changed

+42
-27
lines changed

src/core/pomodoro-timer.js

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -687,70 +687,85 @@ export class PomodoroTimer {
687687
// Track if we need to save session data
688688
let shouldSaveSession = false;
689689

690-
// Skip to next mode
690+
// OVERTIME: If in overtime and continuous sessions, save session and skip double-counting
691+
if (this.timeRemaining < 0 && this.allowContinuousSessions) {
692+
shouldSaveSession = true;
693+
this.sessionCompletedButNotSaved = false;
694+
// Move to next mode as usual
695+
if (this.currentMode === 'focus') {
696+
if (this.completedPomodoros % 4 === 0) {
697+
this.currentMode = 'longBreak';
698+
} else {
699+
this.currentMode = 'break';
700+
}
701+
} else {
702+
this.currentMode = 'focus';
703+
if (this.completedPomodoros < this.totalSessions) {
704+
this.currentSession = this.completedPomodoros + 1;
705+
}
706+
}
707+
this.timeRemaining = this.durations[this.currentMode];
708+
this.updateDisplay();
709+
this.updateButtons();
710+
if (shouldSaveSession) {
711+
this.saveSessionData();
712+
this.updateWeeklyStats();
713+
}
714+
const messages = {
715+
focus: 'Focus session skipped. Time for a break! 😌',
716+
break: 'Break skipped. Ready to focus? 🍅',
717+
longBreak: 'Long break skipped. Time to get back to work! 🚀'
718+
};
719+
NotificationUtils.showNotificationPing(messages[this.currentMode] || 'Session skipped 📤', 'info', this.currentMode);
720+
if (this.autoStartTimer) {
721+
setTimeout(() => {
722+
this.startTimer();
723+
}, 1500);
724+
}
725+
this.updateTrayMenu();
726+
return; // Prevent double-counting
727+
}
728+
729+
// NORMAL SKIP LOGIC
691730
if (this.currentMode === 'focus') {
692-
// Skip focus session - count as completed and go to break
693731
if (!this.sessionCompletedButNotSaved) {
694-
// If session wasn't completed yet (not in overtime), count it as completed
695732
this.completedPomodoros++;
696733
this.updateProgressDots();
697-
698-
// Calculate elapsed time for skipped focus session (partial or full duration)
699734
const actualElapsedTime = this.currentSessionElapsedTime || (this.durations.focus - this.timeRemaining);
700735
this.totalFocusTime += actualElapsedTime;
701-
702-
// Store the actual elapsed time for undo functionality
703736
this.lastCompletedSessionTime = actualElapsedTime;
704737
}
705-
706-
// We need to save session data when skipping a focus session
707738
shouldSaveSession = true;
708739
this.sessionCompletedButNotSaved = false;
709-
710-
// Determine next mode
711740
if (this.completedPomodoros % 4 === 0) {
712741
this.currentMode = 'longBreak';
713742
} else {
714743
this.currentMode = 'break';
715744
}
716745
} else {
717-
// Skip break - go back to focus
718746
this.currentMode = 'focus';
719-
// Only increment session if we haven't reached total sessions
720747
if (this.completedPomodoros < this.totalSessions) {
721748
this.currentSession = this.completedPomodoros + 1;
722749
}
723750
}
724-
725751
this.timeRemaining = this.durations[this.currentMode];
726752
this.updateDisplay();
727753
this.updateButtons();
728-
729-
// Save session data if needed
730754
if (shouldSaveSession) {
731755
this.saveSessionData();
732756
this.updateWeeklyStats();
733757
}
734-
735-
// Show skip notification
736758
const messages = {
737759
focus: 'Focus session skipped. Time for a break! 😌',
738760
break: 'Break skipped. Ready to focus? 🍅',
739761
longBreak: 'Long break skipped. Time to get back to work! 🚀'
740762
};
741-
742763
NotificationUtils.showNotificationPing(messages[this.currentMode] || 'Session skipped 📤', 'info', this.currentMode);
743-
744-
// Auto-start new session if enabled
745764
if (this.autoStartTimer) {
746-
console.log('Auto-starting new session after skip in 1.5 seconds...');
747-
// Add a small delay to let the user see the skip message
748765
setTimeout(() => {
749766
this.startTimer();
750-
}, 1500); // 1.5 second delay
767+
}, 1500);
751768
}
752-
753-
// Update tray menu
754769
this.updateTrayMenu();
755770
}
756771

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
'matrix.css',
4545
'pommodore64.css'

0 commit comments

Comments
 (0)