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

View File

@@ -30,7 +30,6 @@ export interface FocusTaskSettings {
enableCelebrations: boolean; enableCelebrations: boolean;
defaultEstimateMinutes: number; defaultEstimateMinutes: number;
lists: TaskList[]; lists: TaskList[];
showFloatingTimer: true;
autoStartBreak: boolean; autoStartBreak: boolean;
tickSoundEnabled: boolean; tickSoundEnabled: boolean;
} }
@@ -57,7 +56,6 @@ export const DEFAULT_SETTINGS: FocusTaskSettings = {
{ id: 'personal', name: 'Personal', color: '#22c55e', icon: '🏠' }, { id: 'personal', name: 'Personal', color: '#22c55e', icon: '🏠' },
{ id: 'learning', name: 'Learning', color: '#f59e0b', icon: '📚' }, { id: 'learning', name: 'Learning', color: '#f59e0b', icon: '📚' },
], ],
showFloatingTimer: true,
autoStartBreak: false, autoStartBreak: false,
tickSoundEnabled: false, tickSoundEnabled: false,
}; };

View File

@@ -215,18 +215,6 @@
padding: 24px; padding: 24px;
color: white; color: white;
box-shadow: var(--ft-shadow-lg); box-shadow: var(--ft-shadow-lg);
animation: ft-slideIn 0.3s ease;
}
@keyframes ft-slideIn {
from {
opacity: 0;
transform: translateY(-10px);
}
to {
opacity: 1;
transform: translateY(0);
}
} }
.focus-task-break-card { .focus-task-break-card {
@@ -602,7 +590,7 @@
} }
/* ============ Dark mode adjustments ============ */ /* ============ Dark mode adjustments ============ */
.theme-dark .focus-task-floating-timer { .theme-dark .focus-task-status-bar {
background: var(--background-secondary); background: var(--background-secondary);
} }