diff --git a/README.md b/README.md index dc76ff2..24e010a 100644 --- a/README.md +++ b/README.md @@ -66,8 +66,11 @@ Focus Task brings the power of time-boxed task management directly into your Obs ### Manual Installation 1. Download the latest release from the [releases page](https://git.cribdev.com/crib/focus-task/releases) 2. Extract the files to your vault's `.obsidian/plugins/focus-task/` folder -3. Reload Obsidian -4. Enable the plugin in Settings → Community Plugins +3. **⚠️ IMPORTANT**: When updating, do NOT replace or delete the existing `data.json` file - this contains all your tasks, settings, and progress! +4. Reload Obsidian +5. Enable the plugin in Settings → Community Plugins + +> **Note**: Only copy the three plugin files (`main.js`, `manifest.json`, `styles.css`) when updating. Your `data.json` file stores all your tasks and settings and should never be replaced. ### Building from Source ```bash diff --git a/main.js b/main.js index b491147..fae9149 100644 --- a/main.js +++ b/main.js @@ -719,6 +719,8 @@ var FocusTaskPlugin = class extends import_obsidian3.Plugin { const now = Date.now(); const elapsedMs = now - this.timerStartTimestamp; const elapsedSeconds = Math.floor(elapsedMs / 1e3); + if (elapsedSeconds < 1) + return; if (this.isBreakMode) { this.currentTimerSeconds = Math.max(0, this.pausedTimeRemaining - elapsedSeconds); if (this.currentTimerSeconds <= 0) { @@ -743,6 +745,8 @@ var FocusTaskPlugin = class extends import_obsidian3.Plugin { this.focusSecondsToday += elapsedSeconds; } } + this.timerStartTimestamp = now; + this.pausedTimeRemaining = this.currentTimerSeconds; this.updateStatusBar(); this.updateTimerDisplay(); this.saveAllData(); @@ -899,6 +903,7 @@ var FocusTaskPlugin = class extends import_obsidian3.Plugin { const task = this.data.tasks.find((t) => t.id === this.activeTaskId); if (task) { task.isActive = false; + task.actualMinutes = 0; } } this.isTimerRunning = false; diff --git a/src/main.ts b/src/main.ts index 9770864..3c7cb1b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -279,6 +279,9 @@ export default class FocusTaskPlugin extends Plugin { const elapsedMs = now - this.timerStartTimestamp; const elapsedSeconds = Math.floor(elapsedMs / 1000); + // If less than 1 second elapsed, no need to sync + if (elapsedSeconds < 1) return; + if (this.isBreakMode) { // Break mode: countdown timer this.currentTimerSeconds = Math.max(0, this.pausedTimeRemaining - elapsedSeconds); @@ -312,6 +315,10 @@ export default class FocusTaskPlugin extends Plugin { } } + // Reset timestamp to now to prevent double-counting on next sync + this.timerStartTimestamp = now; + this.pausedTimeRemaining = this.currentTimerSeconds; + // Update displays this.updateStatusBar(); this.updateTimerDisplay(); @@ -538,6 +545,9 @@ export default class FocusTaskPlugin extends Plugin { const task = this.data.tasks.find(t => t.id === this.activeTaskId); if (task) { task.isActive = false; + // Reset actual time when manually stopping (not after a break) + // This allows starting fresh next time + task.actualMinutes = 0; } }