diff --git a/com.pdma.notion-timer.sdPlugin/bin/plugin.js b/com.pdma.notion-timer.sdPlugin/bin/plugin.js index 2897e65..e8760e2 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.48"; +var CURRENT_VERSION = "1.0.49"; 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= @@ -6512,7 +6512,8 @@ async function checkForUpdates(sendStatus) { } fs3.writeFileSync(__filename, newCode); plugin_default.logger.info(`Updated to ${version}, restarting\u2026`); - sendStatus?.(`Updated to v${version} \u2014 restarting\u2026`); + await sendStatus?.(`Updated to v${version} \u2014 restarting\u2026`); + await new Promise((resolve) => setTimeout(resolve, 200)); process.exit(0); } catch (err) { const msg = err instanceof Error ? err.message : String(err); @@ -6735,7 +6736,6 @@ plugin_default.ui.onSendToPlugin(async (ev) => { } }); plugin_default.connect(); -sendProjectsToPI(); setTimeout(() => checkForUpdates(), 1e4); /*! Bundled license information: diff --git a/com.pdma.notion-timer.sdPlugin/bin/plugin.js.sig b/com.pdma.notion-timer.sdPlugin/bin/plugin.js.sig index c5ee3f2..4a52926 100644 --- a/com.pdma.notion-timer.sdPlugin/bin/plugin.js.sig +++ b/com.pdma.notion-timer.sdPlugin/bin/plugin.js.sig @@ -1 +1 @@ -Ïìp ¤i§%C‰ÍY9!qTVa¤'R?@·‰~o‰Ÿ.a' ç_‰CXÜfÉ‚&º”V‡+×} ½Ò \ No newline at end of file +sõ¨ÒâËÒŒ›ÍS«ÓúÌuá�¯Is5n²›6äùÑJåë¸ZÏÅh?®†²ª¹È…˜©LJV½?1 \ No newline at end of file diff --git a/com.pdma.notion-timer.sdPlugin/ui/property-inspector.html b/com.pdma.notion-timer.sdPlugin/ui/property-inspector.html index 3dc4c73..5372e0a 100644 --- a/com.pdma.notion-timer.sdPlugin/ui/property-inspector.html +++ b/com.pdma.notion-timer.sdPlugin/ui/property-inspector.html @@ -176,6 +176,21 @@ el.className = cls || ""; } + // The plugin process restarts after an update, and a freshly-restarted + // process has no way to push to an already-open panel (Stream Deck only + // tells a plugin a panel is visible via a live didAppear/onSendToPlugin + // round trip, which a cold-started process hasn't received yet). So the + // panel re-requests the version itself a few times after the restart + // window, instead of waiting on the plugin to notify it. + function pollForVersionRefresh() { + var token = document.getElementById("notionToken").value.trim(); + [1500, 3500, 6000, 9000].forEach(function(delay) { + setTimeout(function() { + $PI.sendToPlugin({ event: "refreshProjects", token: token }); + }, delay); + }); + } + // Collapsible credentials section document.getElementById("credToggle").addEventListener("click", function() { var section = document.getElementById("credSection"); @@ -264,6 +279,7 @@ document.getElementById("updateBtn").addEventListener("click", function() { document.getElementById("updateStatus").textContent = ""; $PI.sendToPlugin({ event: "checkForUpdates" }); + pollForVersionRefresh(); }); }); diff --git a/notion-timer.streamDeckPlugin b/notion-timer.streamDeckPlugin index 3fc5cd1..0cb89ec 100644 Binary files a/notion-timer.streamDeckPlugin and b/notion-timer.streamDeckPlugin differ diff --git a/src/plugin.ts b/src/plugin.ts index a4c2513..6266c27 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -1,4 +1,4 @@ -const CURRENT_VERSION = "1.0.48"; +const CURRENT_VERSION = "1.0.49"; 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= @@ -19,7 +19,7 @@ function fetchWithTimeout(url: string): Promise { return fetch(url, { signal: controller.signal }).finally(() => clearTimeout(timer)); } -async function checkForUpdates(sendStatus?: (msg: string) => void): Promise { +async function checkForUpdates(sendStatus?: (msg: string) => void | Promise): Promise { try { const resp = await fetchWithTimeout(`${GITEA_BASE}/version.json`); if (!resp.ok) { sendStatus?.("Update check failed"); return; } @@ -73,7 +73,11 @@ async function checkForUpdates(sendStatus?: (msg: string) => void): Promise setTimeout(resolve, 200)); process.exit(0); } catch (err) { const msg = err instanceof Error ? err.message : String(err); @@ -350,10 +354,4 @@ streamDeck.ui.onSendToPlugin<{ event: string; settings?: TimerSettings; token?: streamDeck.connect(); -// If a Property Inspector is already open (e.g. it survived the restart -// that just happened after an auto-update), push it the now-current -// version immediately — otherwise it keeps showing the pre-update number -// until the user happens to click a different button and reopens it. -sendProjectsToPI(); - setTimeout(() => checkForUpdates(), 10_000); diff --git a/version.json b/version.json index 3c51086..9fc6242 100644 --- a/version.json +++ b/version.json @@ -1 +1 @@ -{ "version": "1.0.48" } +{ "version": "1.0.49" }