diff --git a/com.pdma.notion-timer.sdPlugin/bin/plugin.js b/com.pdma.notion-timer.sdPlugin/bin/plugin.js index d3b8621..40bbfa8 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.38"; +var CURRENT_VERSION = "1.0.39"; 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= @@ -6535,11 +6535,10 @@ async function loadRunningState() { memRunningEntryId = stored.runningEntryId ?? null; memRunningActionId = stored.runningActionId ?? null; } -async function setRunningEntry(entryId, actionId) { +function setRunningEntry(entryId, actionId) { memRunningEntryId = entryId; memRunningActionId = actionId; - const stored = await plugin_default.settings.getGlobalSettings(); - await plugin_default.settings.setGlobalSettings({ ...stored, runningEntryId: entryId, runningActionId: actionId }); + plugin_default.settings.getGlobalSettings().then((stored) => plugin_default.settings.setGlobalSettings({ ...stored, runningEntryId: entryId, runningActionId: actionId })).catch((err) => plugin_default.logger.error("Failed to persist running state:", err)); } async function sendProjectsToPI(tokenOverride) { try { @@ -6614,13 +6613,15 @@ var TimerToggle = class extends SingletonAction { try { if (isRunning) { await stopTimer(global.notionToken, memRunningEntryId); - await setRunningEntry(null, null); + setRunningEntry(null, null); + await Promise.all([ev.action.setState(0), ev.action.setTitle(title)]); } else { if (memRunningEntryId) { await stopTimer(global.notionToken, memRunningEntryId); } const entryId = await startTimer(global.notionToken, global.timingDbId, projectId, projectName, global.userId); - await setRunningEntry(entryId, ev.action.id); + setRunningEntry(entryId, ev.action.id); + await Promise.all([ev.action.setState(1), ev.action.setTitle(`\u23F1 ${title}`)]); } } catch (err) { await Promise.all([ diff --git a/com.pdma.notion-timer.sdPlugin/bin/plugin.js.sig b/com.pdma.notion-timer.sdPlugin/bin/plugin.js.sig index 287a506..6e5d5af 100644 --- a/com.pdma.notion-timer.sdPlugin/bin/plugin.js.sig +++ b/com.pdma.notion-timer.sdPlugin/bin/plugin.js.sig @@ -1,2 +1 @@ -ʤCSߤ -֮}~P }̘Z;x{,NYPu4#ʄj᧾WC긩 d \ No newline at end of file +<!xRڄR;=LI" ѤHuFُӀ sbY{H.JN1l \ 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 a569280..3c54c51 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.38", + "Version": "1.0.39", "SDKVersion": 2, "Software": { "MinimumVersion": "5.0" }, "OS": [{ "Platform": "mac", "MinimumVersion": "10.11" }], diff --git a/src/plugin.ts b/src/plugin.ts index aed18c0..f6cf24d 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -1,4 +1,4 @@ -const CURRENT_VERSION = "1.0.38"; +const CURRENT_VERSION = "1.0.39"; 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= @@ -125,11 +125,13 @@ async function loadRunningState(): Promise { memRunningActionId = stored.runningActionId ?? null; } -async function setRunningEntry(entryId: string | null, actionId: string | null): Promise { +function setRunningEntry(entryId: string | null, actionId: string | null): void { memRunningEntryId = entryId; memRunningActionId = actionId; - const stored = await streamDeck.settings.getGlobalSettings(); - await streamDeck.settings.setGlobalSettings({ ...stored, runningEntryId: entryId, runningActionId: actionId }); + // Persist in background — do not await, so the visual is never blocked + streamDeck.settings.getGlobalSettings() + .then(stored => streamDeck.settings.setGlobalSettings({ ...stored, runningEntryId: entryId, runningActionId: actionId })) + .catch(err => streamDeck.logger.error("Failed to persist running state:", err)); } async function sendProjectsToPI(tokenOverride?: string): Promise { @@ -210,13 +212,15 @@ class TimerToggle extends SingletonAction { try { if (isRunning) { await stopTimer(global.notionToken, memRunningEntryId!); - await setRunningEntry(null, null); + setRunningEntry(null, null); + await Promise.all([ev.action.setState(0), ev.action.setTitle(title)]); } else { if (memRunningEntryId) { await stopTimer(global.notionToken, memRunningEntryId); } const entryId = await startTimer(global.notionToken, global.timingDbId, projectId, projectName, global.userId); - await setRunningEntry(entryId, ev.action.id); + setRunningEntry(entryId, ev.action.id); + await Promise.all([ev.action.setState(1), ev.action.setTitle(`⏱ ${title}`)]); } } catch (err) { // Revert visual on error diff --git a/version.json b/version.json index f8f6453..a1b6356 100644 --- a/version.json +++ b/version.json @@ -1 +1 @@ -{ "version": "1.0.38" } +{ "version": "1.0.39" }