Skip to content

Commit

Permalink
Merge branch 'master' into api-migration
Browse files Browse the repository at this point in the history
  • Loading branch information
mcndt committed Feb 27, 2022
2 parents 29a94c3 + 4621285 commit 42f19a8
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 15 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/model/Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface Project {
/**
* Project ID in Toggl API
*/
id: string;
id: number;

/**
* Client ID for the project
Expand Down
19 changes: 17 additions & 2 deletions lib/toggl/TogglManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script lang="ts">
import { ApiStatus } from 'lib/toggl/TogglManager';
import { apiStatusStore, togglStore } from 'lib/util/stores';
import { togglStore } from 'lib/util/stores';
export let buttonSize = 36;
Expand Down Expand Up @@ -30,11 +29,11 @@
<style>
.timer-start-button {
--button-fill-outer: var(--interactive-accent);
--button-fill-inner: var(--interactive-normal);
--button-fill-inner: var(--background-primary);
}
.timer-start-button:hover {
--button-fill-outer: var(--interactive-accent-hover);
--button-fill-inner: var(--interactive-hover);
--button-fill-inner: var(--background-secondary);
}
</style>
7 changes: 3 additions & 4 deletions lib/ui/components/current_timer/CurrentTimerStopButton.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script lang="ts">
import { ApiStatus } from 'lib/toggl/TogglManager';
import { apiStatusStore, togglStore } from 'lib/util/stores';
import { togglStore } from 'lib/util/stores';
export let buttonSize = 36;
Expand Down Expand Up @@ -32,11 +31,11 @@
<style>
.timer-stop-button {
--button-fill-outer: var(--interactive-accent);
--button-fill-inner: var(--interactive-normal);
--button-fill-inner: var(--background-primary);
}
.timer-stop-button:hover {
--button-fill-outer: var(--interactive-accent-hover);
--button-fill-inner: var(--interactive-hover);
--button-fill-inner: var(--background-secondary);
}
</style>
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-toggl-integration",
"name": "Toggl Track",
"version": "0.7.1",
"version": "0.7.2",
"minAppVersion": "0.11.13",
"description": "Manage timers and generate time reports using Toggl Track without leaving Obsidian.",
"author": "Maxime Cannoodt (@mcndt)",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-toggl-integration",
"version": "0.7.1",
"version": "0.7.2",
"description": "Manage timers and generate time reports using Toggl Track without leaving Obsidian.",
"main": "main.js",
"files": [
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"0.6.0": "0.11.13",
"0.6.1": "0.11.13",
"0.7.0": "0.11.13",
"0.7.1": "0.11.13"
"0.7.1": "0.11.13",
"0.7.2": "0.11.13"
}

0 comments on commit 42f19a8

Please sign in to comment.