From 343d0d98096ff00813edb4caf5aa054ec0270582 Mon Sep 17 00:00:00 2001 From: Sayuop Date: Sat, 22 Nov 2025 14:25:27 +0100 Subject: [PATCH] Bug-fixes --- src/main.ts | 82 +++++++++++++++++++++++++++------------------------ src/modals.ts | 2 +- src/types.ts | 4 +-- styles.css | 36 ++++++++-------------- 4 files changed, 58 insertions(+), 66 deletions(-) diff --git a/src/main.ts b/src/main.ts index c04d9d9..f600623 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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 {

`; } -} +} \ No newline at end of file diff --git a/src/modals.ts b/src/modals.ts index 40e5b3e..834413e 100644 --- a/src/modals.ts +++ b/src/modals.ts @@ -201,4 +201,4 @@ export class EditTaskModal extends Modal { const { contentEl } = this; contentEl.empty(); } -} +} \ No newline at end of file diff --git a/src/types.ts b/src/types.ts index 9b6b5ea..83488e6 100644 --- a/src/types.ts +++ b/src/types.ts @@ -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!' }, -]; +]; \ No newline at end of file diff --git a/styles.css b/styles.css index 3c661db..9433c12 100644 --- a/styles.css +++ b/styles.css @@ -215,18 +215,6 @@ padding: 24px; color: white; 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 { @@ -514,22 +502,22 @@ /* ============ Status Bar Timer ============ */ .focus-task-status-bar { - cursor: pointer; - padding: 0 8px; - display: flex; - align-items: center; - gap: 4px; - font-size: 12px; - transition: all 0.2s ease; + cursor: pointer; + padding: 0 8px; + display: flex; + align-items: center; + gap: 4px; + font-size: 12px; + transition: all 0.2s ease; } .focus-task-status-bar:hover { - color: var(--text-accent); + color: var(--text-accent); } .focus-task-status-bar.focus-task-status-active { - color: var(--text-accent); - font-weight: 500; + color: var(--text-accent); + font-weight: 500; } /* ============ Modal Styles ============ */ @@ -602,7 +590,7 @@ } /* ============ Dark mode adjustments ============ */ -.theme-dark .focus-task-floating-timer { +.theme-dark .focus-task-status-bar { background: var(--background-secondary); } @@ -633,4 +621,4 @@ justify-content: flex-end; margin-top: 8px; } -} +} \ No newline at end of file