diff --git a/CHANGELOG.md b/CHANGELOG.md index cdec52f..3252c3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,18 @@ # Changelog -## [0.7.2] +## [0.7.3] ### ⚙️ Internal - When installed on API version 0.13.25 or higher, the plugin now uses Obsidian's own `requestUrl` API instead of the third-party dependency `got`. This lays the foundation for supporting Mobile platforms in the future. +## [0.7.2] + +### 🐛 Fixes + +- Fix timers having "Unknown project" on opening Obsidian (issue #32) +- Fixed the start/stop button accent color to be more accessible on Minimal Theme (issue #67) + ## [0.7.1] ### ✨ Features diff --git a/lib/model/Project.ts b/lib/model/Project.ts index d29fd88..98fb0f8 100644 --- a/lib/model/Project.ts +++ b/lib/model/Project.ts @@ -7,7 +7,7 @@ export interface Project { /** * Project ID in Toggl API */ - id: string; + id: number; /** * Client ID for the project diff --git a/lib/toggl/TogglManager.ts b/lib/toggl/TogglManager.ts index c4c8c6b..f8408e5 100644 --- a/lib/toggl/TogglManager.ts +++ b/lib/toggl/TogglManager.ts @@ -92,6 +92,21 @@ export default class TogglManager { private async _preloadWorkspaceData() { this._apiManager.getProjects().then((response: Project[]) => { this._projects = response; + + // Update the current timer if it was fetched before the preload finished. + currentTimer.update((entry) => { + if (entry && entry.pid !== undefined) { + const project = response.find((p) => p.id === entry.pid); + return { + ...entry, + project: project.name, + project_hex_color: project.hex_color + }; + } + return entry; + }); + + // if there is already a timer running, add the project name. }); this._apiManager.getTags().then((response: Tag[]) => { this._tags = response; @@ -142,7 +157,7 @@ export default class TogglManager { if (new_timer == null) { const project = await this._plugin.input.selectProject(); new_timer = await this._plugin.input.enterTimerDetails(); - new_timer.pid = project != null ? parseInt(project.id) : null; + new_timer.pid = project != null ? project.id : null; } this._apiManager.startTimer(new_timer).then((t: TimeEntry) => { @@ -415,7 +430,7 @@ export default class TogglManager { // NOTE: relies on cached projects for project names private responseToTimeEntry(response: any): TimeEntry { - let project = this.cachedProjects.find((p) => p.id == response.pid); + const project = this.cachedProjects.find((p) => p.id == response.pid); return { description: response.description, pid: response.pid, diff --git a/lib/ui/components/current_timer/CurrentTimerStartButton.svelte b/lib/ui/components/current_timer/CurrentTimerStartButton.svelte index 0b144d2..a0b84a9 100644 --- a/lib/ui/components/current_timer/CurrentTimerStartButton.svelte +++ b/lib/ui/components/current_timer/CurrentTimerStartButton.svelte @@ -1,6 +1,5 @@