Release v1.0.7: General bugfixes
This commit is contained in:
19
src/main.ts
19
src/main.ts
@@ -116,8 +116,17 @@ export default class FocusTaskPlugin extends Plugin {
|
||||
|
||||
async loadAllData() {
|
||||
const loaded = await this.loadData();
|
||||
|
||||
// Merge loaded data with defaults (defaults first, then override with loaded)
|
||||
// This ensures new fields get default values even for existing installs
|
||||
this.data = Object.assign({}, DEFAULT_DATA, loaded?.data || {});
|
||||
this.settings = Object.assign({}, DEFAULT_SETTINGS, loaded?.settings || {});
|
||||
|
||||
// Ensure lists array exists and has at least the default lists
|
||||
if (!this.settings.lists || this.settings.lists.length === 0) {
|
||||
this.settings.lists = DEFAULT_SETTINGS.lists;
|
||||
}
|
||||
|
||||
// Initialize seconds from stored minutes
|
||||
this.focusSecondsToday = (this.data.totalFocusMinutesToday || 0) * 60;
|
||||
}
|
||||
@@ -369,7 +378,8 @@ export default class FocusTaskPlugin extends Plugin {
|
||||
this.isTimerRunning = true;
|
||||
|
||||
// Initialize from existing actual time to preserve progress across breaks
|
||||
this.secondsWorkedOnCurrentTask = task.actualMinutes * 60;
|
||||
// Store as seconds for precision
|
||||
this.secondsWorkedOnCurrentTask = Math.floor(task.actualMinutes * 60);
|
||||
|
||||
// Set timestamp for background tracking (pomodoro countdown mode)
|
||||
this.timerStartTimestamp = Date.now();
|
||||
@@ -384,7 +394,12 @@ export default class FocusTaskPlugin extends Plugin {
|
||||
|
||||
if (!this.isBreakMode) {
|
||||
this.secondsWorkedOnCurrentTask++;
|
||||
task.actualMinutes = Math.floor(this.secondsWorkedOnCurrentTask / 60);
|
||||
// Calculate actual minutes from total seconds worked
|
||||
const actualMinutes = Math.floor(this.secondsWorkedOnCurrentTask / 60);
|
||||
// Only update if changed to avoid unnecessary updates
|
||||
if (task.actualMinutes !== actualMinutes) {
|
||||
task.actualMinutes = actualMinutes;
|
||||
}
|
||||
// Increment focus time by 1 second
|
||||
this.focusSecondsToday++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user