Bug-fixes

This commit is contained in:
2025-11-22 14:25:27 +01:00
parent 4303bfa2e6
commit 343d0d9809
4 changed files with 58 additions and 66 deletions

View File

@@ -36,7 +36,7 @@ export default class FocusTaskPlugin extends Plugin {
activeTaskId: string | null = null;
pomodoroCount: number = 0;
// Status Bar element
// Status bar element
statusBarEl: HTMLElement | null = null;
async onload() {
@@ -90,14 +90,13 @@ export default class FocusTaskPlugin extends Plugin {
// Add settings tab
this.addSettingTab(new FocusTaskSettingTab(this.app, this));
// Create floating timer if enabled
// Create status bar timer
this.createStatusBar();
}
onunload() {
this.stopTimer();
}
this.stopTimer();
}
async loadAllData() {
const loaded = await this.loadData();
@@ -251,14 +250,18 @@ export default class FocusTaskPlugin extends Plugin {
this.currentTimerSeconds = 0;
this.isTimerRunning = true;
// Full refresh to show the active task card
this.refreshView();
this.updateStatusBar();
// Start interval (count up mode - stopwatch)
this.timerInterval = window.setInterval(() => {
this.currentTimerSeconds++;
task.actualMinutes = Math.floor(this.currentTimerSeconds / 60);
// Update floating timer
this.updateFloatingTimer();
this.refreshView();
// Light update - only timer display, no full refresh
this.updateStatusBar();
this.updateTimerDisplay();
// Check if over estimate
if (this.currentTimerSeconds === task.estimatedMinutes * 60) {
@@ -270,8 +273,6 @@ export default class FocusTaskPlugin extends Plugin {
}, 1000);
this.saveAllData();
this.updateTimerDisplay();
this.updateFloatingTimer();
}
startPomodoro(taskId: string) {
@@ -285,6 +286,10 @@ export default class FocusTaskPlugin extends Plugin {
this.currentTimerSeconds = this.settings.pomodoroWorkMinutes * 60;
this.isTimerRunning = true;
// Full refresh to show the active task card
this.refreshView();
this.updateStatusBar();
this.timerInterval = window.setInterval(() => {
this.currentTimerSeconds--;
@@ -293,16 +298,14 @@ export default class FocusTaskPlugin extends Plugin {
this.data.totalFocusMinutesToday = Math.floor(this.data.totalFocusMinutesToday + 1/60);
}
this.updateFloatingTimer();
this.refreshView();
// Light update - only timer display, no full refresh
this.updateStatusBar();
this.updateTimerDisplay();
if (this.currentTimerSeconds <= 0) {
this.handlePomodoroEnd();
}
}, 1000);
this.updateFloatingTimer();
this.updateTimerDisplay();
}
handlePomodoroEnd() {
@@ -342,11 +345,15 @@ export default class FocusTaskPlugin extends Plugin {
new Notice(isLongBreak ? '☕ Long break time!' : '☕ Short break time!');
// Full refresh to show break state
this.refreshView();
if (!this.timerInterval) {
this.timerInterval = window.setInterval(() => {
this.currentTimerSeconds--;
this.updateFloatingTimer();
this.refreshView();
// Light update - only timer display
this.updateStatusBar();
this.updateTimerDisplay();
if (this.currentTimerSeconds <= 0) {
this.handlePomodoroEnd();
@@ -354,8 +361,7 @@ export default class FocusTaskPlugin extends Plugin {
}, 1000);
}
this.updateFloatingTimer();
this.updateTimerDisplay();
this.updateStatusBar();
}
toggleTimer() {
@@ -374,8 +380,9 @@ export default class FocusTaskPlugin extends Plugin {
if (task && !this.isBreakMode) {
task.actualMinutes = Math.floor((this.settings.pomodoroWorkMinutes * 60 - this.currentTimerSeconds) / 60);
}
this.updateFloatingTimer();
this.refreshView();
// Light update - only timer display
this.updateStatusBar();
this.updateTimerDisplay();
if (this.currentTimerSeconds <= 0) {
this.handlePomodoroEnd();
@@ -385,8 +392,9 @@ export default class FocusTaskPlugin extends Plugin {
new Notice('No active task. Select a task first.');
}
this.updateFloatingTimer();
this.updateTimerDisplay();
// Full refresh to update pause/resume button state
this.updateStatusBar();
this.refreshView();
}
stopTimer() {
@@ -404,8 +412,9 @@ export default class FocusTaskPlugin extends Plugin {
this.isTimerRunning = false;
this.activeTaskId = null;
this.updateFloatingTimer();
this.updateStatusBar();
this.saveAllData();
this.refreshView();
}
startFocusOnNextTask() {
@@ -419,18 +428,18 @@ export default class FocusTaskPlugin extends Plugin {
// ============ Status Bar Timer ============
createStatusBar() {
this.statusBarEl = this.addStatusBarItem();
this.statusBarEl.addClass('focus-task-status-bar');
this.updateStatusBar();
// Click to open panel
this.statusBarEl.addEventListener('click', () => {
this.activateView();
});
createStatusBar() {
this.statusBarEl = this.addStatusBarItem();
this.statusBarEl.addClass('focus-task-status-bar');
this.updateStatusBar();
// Click to open panel
this.statusBarEl.addEventListener('click', () => {
this.activateView();
});
}
updateStatusBar() {
updateStatusBar() {
if (!this.statusBarEl) return;
if (this.activeTaskId) {
@@ -447,8 +456,6 @@ export default class FocusTaskPlugin extends Plugin {
}
}
// ============ Sounds & Celebrations ============
showCelebration(task: FocusTask) {
@@ -701,7 +708,6 @@ class FocusTaskSettingTab extends PluginSettingTab {
await this.plugin.saveAllData();
}));
// Lists Management
containerEl.createEl('h2', { text: '📋 Lists' });
@@ -766,4 +772,4 @@ class FocusTaskSettingTab extends PluginSettingTab {
</p>
`;
}
}
}

View File

@@ -201,4 +201,4 @@ export class EditTaskModal extends Modal {
const { contentEl } = this;
contentEl.empty();
}
}
}

View File

@@ -30,7 +30,6 @@ export interface FocusTaskSettings {
enableCelebrations: boolean;
defaultEstimateMinutes: number;
lists: TaskList[];
showFloatingTimer: true;
autoStartBreak: boolean;
tickSoundEnabled: boolean;
}
@@ -57,7 +56,6 @@ export const DEFAULT_SETTINGS: FocusTaskSettings = {
{ id: 'personal', name: 'Personal', color: '#22c55e', icon: '🏠' },
{ id: 'learning', name: 'Learning', color: '#f59e0b', icon: '📚' },
],
showFloatingTimer: true,
autoStartBreak: false,
tickSoundEnabled: false,
};
@@ -98,4 +96,4 @@ export const OVERTIME_MESSAGES = [
{ emoji: '💪', message: 'Persistence pays off!' },
{ emoji: '🏃', message: 'Marathon runner!' },
{ emoji: '🔥', message: 'The grind is real!' },
];
];