diff --git a/com.pdma.notion-timer.sdPlugin/bin/plugin.js b/com.pdma.notion-timer.sdPlugin/bin/plugin.js index 022e76d..4398be8 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.25"; +var CURRENT_VERSION = "1.0.26"; var GITEA_BASE = "https://gitea.pdmarf.co.uk/pdm/stream_deck_notion_timer/raw/branch/master"; var SIGNING_PUBLIC_KEY = `-----BEGIN PUBLIC KEY----- MCowBQYDK2VwAyEAN7ko8TUpuPzPAJuKAZCRjV0c4ZSlou5d9pUAF6o12b4= @@ -6589,6 +6589,16 @@ var TimerToggle = class extends SingletonAction { await setRunningEntry(null); } 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 Promise.all([ev.action.setState(1), ev.action.setTitle(`\u23F1 ${title}`)]); if (prevEntryId) { await stopTimer(global.notionToken, prevEntryId); for (const other of this.actions) { @@ -6598,8 +6608,6 @@ var TimerToggle = class extends SingletonAction { const stopped = { ...otherSettings, activeEntryId: null }; await other.setSettings(stopped); this.settingsCache.set(other.id, stopped); - await other.setState(0); - await other.setTitle(buttonTitle(otherSettings.projectName || "")); } } } @@ -6614,8 +6622,6 @@ var TimerToggle = class extends SingletonAction { await ev.action.setSettings(started); this.settingsCache.set(ev.action.id, started); await setRunningEntry(entryId); - await ev.action.setState(1); - await ev.action.setTitle(`\u23F1 ${title}`); } } catch (err) { plugin_default.logger.error("Timer toggle failed:", err); diff --git a/com.pdma.notion-timer.sdPlugin/bin/plugin.js.sig b/com.pdma.notion-timer.sdPlugin/bin/plugin.js.sig index d1817a8..86c3f4c 100644 --- a/com.pdma.notion-timer.sdPlugin/bin/plugin.js.sig +++ b/com.pdma.notion-timer.sdPlugin/bin/plugin.js.sig @@ -1,3 +1,2 @@ -Һ -HJ{l >0^tq2lZ +e>W%"Y8ge8B$>W=kIďMe2K \ No newline at end of file diff --git a/com.pdma.notion-timer.sdPlugin/manifest.json b/com.pdma.notion-timer.sdPlugin/manifest.json index 76b72fc..8461c55 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.25", + "Version": "1.0.26", "SDKVersion": 2, "Software": { "MinimumVersion": "5.0" }, "OS": [{ "Platform": "mac", "MinimumVersion": "10.11" }], diff --git a/notion-timer.streamDeckPlugin b/notion-timer.streamDeckPlugin index d25c9f2..37993c2 100644 Binary files a/notion-timer.streamDeckPlugin and b/notion-timer.streamDeckPlugin differ diff --git a/src/plugin.ts b/src/plugin.ts index 0b40fcb..b611d66 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -1,4 +1,4 @@ -const CURRENT_VERSION = "1.0.25"; +const CURRENT_VERSION = "1.0.26"; const GITEA_BASE = "https://gitea.pdmarf.co.uk/pdm/stream_deck_notion_timer/raw/branch/master"; const SIGNING_PUBLIC_KEY = `-----BEGIN PUBLIC KEY----- MCowBQYDK2VwAyEAN7ko8TUpuPzPAJuKAZCRjV0c4ZSlou5d9pUAF6o12b4= @@ -195,7 +195,19 @@ class TimerToggle extends SingletonAction { } else { const prevEntryId = await getRunningEntryId(); - // Stop previous timer + // Optimistically update visuals immediately — no waiting for API + 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 Promise.all([ev.action.setState(1), ev.action.setTitle(`⏱ ${title}`)]); + + // Now do the API calls if (prevEntryId) { await stopTimer(global.notionToken, prevEntryId); for (const other of this.actions) { @@ -205,8 +217,6 @@ class TimerToggle extends SingletonAction { const stopped = { ...otherSettings, activeEntryId: null }; await other.setSettings(stopped); this.settingsCache.set(other.id, stopped); - await other.setState(0); - await other.setTitle(buttonTitle(otherSettings.projectName || "")); } } } @@ -222,8 +232,6 @@ class TimerToggle extends SingletonAction { await ev.action.setSettings(started); this.settingsCache.set(ev.action.id, started); await setRunningEntry(entryId); - await ev.action.setState(1); - await ev.action.setTitle(`⏱ ${title}`); } } catch (err) { streamDeck.logger.error("Timer toggle failed:", err);