v1.0.49: fix version auto-refresh by polling from the property inspector
The v1.0.47/48 attempt pushed sendProjectsToPI() from the plugin right after streamDeck.connect() on startup, assuming that would reach an already-open panel post-update-restart. It doesn't: per the SDK, sendToPropertyInspector only delivers 'when the property inspector is visible for an action provided by this plugin', and that visibility state is tracked per-process via live didAppear/onSendToPlugin events -- a freshly restarted process has never received one, so the push was silently dropped. Confirmed in testing: the panel stayed frozen on 'Updating to vX...' indefinitely. Removed the ineffective push. Instead, the property inspector's 'Check for Updates' handler now schedules a few refreshProjects requests (1.5s/3.5s/6s/9s after the click) -- the same proven PI-initiated round trip already used when entering an API token, which reliably re-populates the panel including the version text once the new process comes back up. Also hardened checkForUpdates(): the final 'Updated to vX -- restarting...' status is now awaited with a short delay before process.exit(0), best-effort only, since the panel no longer depends on it arriving.
This commit is contained in:
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user