diff --git a/com.pdma.notion-timer.sdPlugin/bin/plugin.js b/com.pdma.notion-timer.sdPlugin/bin/plugin.js index a0451ff..4eca5f3 100644 --- a/com.pdma.notion-timer.sdPlugin/bin/plugin.js +++ b/com.pdma.notion-timer.sdPlugin/bin/plugin.js @@ -6438,7 +6438,7 @@ async function stopTimer(token, entryId) { } // src/plugin.ts -var CURRENT_VERSION = "1.0.33"; +var CURRENT_VERSION = "1.0.34"; var GITEA_BASE = "https://gitea.pdmarf.co.uk/pdm/stream_deck_notion_timer/raw/branch/stable-rebuild"; var SIGNING_PUBLIC_KEY = `-----BEGIN PUBLIC KEY----- MCowBQYDK2VwAyEAN7ko8TUpuPzPAJuKAZCRjV0c4ZSlou5d9pUAF6o12b4= @@ -6599,6 +6599,13 @@ var TimerToggle = class extends SingletonAction { if (activeEntryId) { await Promise.all([ev.action.setState(0), ev.action.setTitle(title)]); } else { + for (const other of this.actions) { + if (other.id === ev.action.id) continue; + const otherSettings = this.settingsCache.get(other.id); + if (otherSettings?.activeEntryId) { + await Promise.all([other.setState(0), other.setTitle(buttonTitle(otherSettings.projectName || ""))]); + } + } await Promise.all([ev.action.setState(1), ev.action.setTitle(`\u23F1 ${title}`)]); } } @@ -6622,13 +6629,6 @@ var TimerToggle = class extends SingletonAction { } else { const prevEntryId = await getRunningEntryId(); if (prevEntryId) { - for (const other of this.actions) { - if (other.id === ev.action.id) continue; - const otherSettings = this.settingsCache.get(other.id); - if (otherSettings?.activeEntryId === prevEntryId) { - await Promise.all([other.setState(0), other.setTitle(buttonTitle(otherSettings.projectName || ""))]); - } - } await stopTimer(global.notionToken, prevEntryId); for (const other of this.actions) { if (other.id === ev.action.id) continue; diff --git a/com.pdma.notion-timer.sdPlugin/bin/plugin.js.sig b/com.pdma.notion-timer.sdPlugin/bin/plugin.js.sig index 16c9287..60549bc 100644 Binary files a/com.pdma.notion-timer.sdPlugin/bin/plugin.js.sig and b/com.pdma.notion-timer.sdPlugin/bin/plugin.js.sig differ diff --git a/com.pdma.notion-timer.sdPlugin/manifest.json b/com.pdma.notion-timer.sdPlugin/manifest.json index 90dce3e..6be727b 100644 --- a/com.pdma.notion-timer.sdPlugin/manifest.json +++ b/com.pdma.notion-timer.sdPlugin/manifest.json @@ -2,7 +2,7 @@ "Author": "Pete Marfleet", "Description": "Toggle Notion time tracking for a project with a single button press.", "Name": "Notion Timer", - "Version": "1.0.33", + "Version": "1.0.34", "SDKVersion": 2, "Software": { "MinimumVersion": "5.0" }, "OS": [{ "Platform": "mac", "MinimumVersion": "10.11" }], diff --git a/notion-timer.streamDeckPlugin b/notion-timer.streamDeckPlugin index 7d03184..da4ea66 100644 Binary files a/notion-timer.streamDeckPlugin and b/notion-timer.streamDeckPlugin differ diff --git a/src/plugin.ts b/src/plugin.ts index 6d19266..13a9fdf 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -1,4 +1,4 @@ -const CURRENT_VERSION = "1.0.33"; +const CURRENT_VERSION = "1.0.34"; const GITEA_BASE = "https://gitea.pdmarf.co.uk/pdm/stream_deck_notion_timer/raw/branch/stable-rebuild"; const SIGNING_PUBLIC_KEY = `-----BEGIN PUBLIC KEY----- MCowBQYDK2VwAyEAN7ko8TUpuPzPAJuKAZCRjV0c4ZSlou5d9pUAF6o12b4= @@ -206,6 +206,14 @@ class TimerToggle extends SingletonAction { if (activeEntryId) { await Promise.all([ev.action.setState(0), ev.action.setTitle(title)]); } else { + // Turn off any other running button immediately using the cache — no async needed + for (const other of this.actions) { + if (other.id === ev.action.id) continue; + const otherSettings = this.settingsCache.get(other.id); + if (otherSettings?.activeEntryId) { + await Promise.all([other.setState(0), other.setTitle(buttonTitle(otherSettings.projectName || ""))]); + } + } await Promise.all([ev.action.setState(1), ev.action.setTitle(`⏱ ${title}`)]); } } @@ -233,15 +241,8 @@ class TimerToggle extends SingletonAction { } else { const prevEntryId = await getRunningEntryId(); - // Turn off the previously running button immediately + // Stop previous timer and update its settings if (prevEntryId) { - for (const other of this.actions) { - if (other.id === ev.action.id) continue; - const otherSettings = this.settingsCache.get(other.id); - if (otherSettings?.activeEntryId === prevEntryId) { - await Promise.all([other.setState(0), other.setTitle(buttonTitle(otherSettings.projectName || ""))]); - } - } await stopTimer(global.notionToken, prevEntryId); for (const other of this.actions) { if (other.id === ev.action.id) continue; diff --git a/version.json b/version.json index 5c1b696..020e2df 100644 --- a/version.json +++ b/version.json @@ -1 +1 @@ -{ "version": "1.0.33" } +{ "version": "1.0.34" }