v1.0.29: fix userId not restoring due to race condition

onSendToPropertyInspector (users list) arrives before
onDidReceiveGlobalSettings (saved userId) in most cases, leaving
globalUserId empty when populateUsers runs. Now cachedUsers stores
the list, and onDidReceiveGlobalSettings re-populates if users
already arrived — handles both orderings.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
pdmarf
2026-04-24 08:53:15 +01:00
parent c3add8da27
commit ccc6d90578
7 changed files with 12 additions and 14 deletions

View File

@@ -6438,7 +6438,7 @@ async function stopTimer(token, entryId) {
} }
// src/plugin.ts // src/plugin.ts
var CURRENT_VERSION = "1.0.28"; var CURRENT_VERSION = "1.0.29";
var GITEA_BASE = "https://gitea.pdmarf.co.uk/pdm/stream_deck_notion_timer/raw/branch/stable-rebuild"; var GITEA_BASE = "https://gitea.pdmarf.co.uk/pdm/stream_deck_notion_timer/raw/branch/stable-rebuild";
var SIGNING_PUBLIC_KEY = `-----BEGIN PUBLIC KEY----- var SIGNING_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
MCowBQYDK2VwAyEAN7ko8TUpuPzPAJuKAZCRjV0c4ZSlou5d9pUAF6o12b4= MCowBQYDK2VwAyEAN7ko8TUpuPzPAJuKAZCRjV0c4ZSlou5d9pUAF6o12b4=

View File

@@ -1,2 +1 @@
©╬и$q йщJОЁ▀⌠Ы╚▓яU(д┘Ж░░8ДОЬMJv ё√шHАXаJ┌╗∙И╧OУнаеC╔/эУ6╩
PИэ

View File

@@ -2,7 +2,7 @@
"Author": "Pete Marfleet", "Author": "Pete Marfleet",
"Description": "Toggle Notion time tracking for a project with a single button press.", "Description": "Toggle Notion time tracking for a project with a single button press.",
"Name": "Notion Timer", "Name": "Notion Timer",
"Version": "1.0.28", "Version": "1.0.29",
"SDKVersion": 2, "SDKVersion": 2,
"Software": { "MinimumVersion": "5.0" }, "Software": { "MinimumVersion": "5.0" },
"OS": [{ "Platform": "mac", "MinimumVersion": "10.11" }], "OS": [{ "Platform": "mac", "MinimumVersion": "10.11" }],

View File

@@ -162,6 +162,7 @@
var credSaveTimer = null; var credSaveTimer = null;
var credConfigured = false; var credConfigured = false;
var globalUserId = ""; var globalUserId = "";
var cachedUsers = [];
function setStatus(msg, cls) { function setStatus(msg, cls) {
var el = document.getElementById("statusText"); var el = document.getElementById("statusText");
@@ -201,15 +202,15 @@
} }
} }
function populateUsers(users, savedUserId) { function populateUsers(users, userId) {
cachedUsers = users;
var sel = document.getElementById("userId"); var sel = document.getElementById("userId");
var current = savedUserId || sel.value;
sel.innerHTML = '<option value="">— Select your name —</option>'; sel.innerHTML = '<option value="">— Select your name —</option>';
users.forEach(function(u) { users.forEach(function(u) {
var opt = document.createElement("option"); var opt = document.createElement("option");
opt.value = u.id; opt.value = u.id;
opt.textContent = u.name; opt.textContent = u.name;
if (u.id === current) opt.selected = true; if (u.id === userId) opt.selected = true;
sel.appendChild(opt); sel.appendChild(opt);
}); });
} }
@@ -266,11 +267,9 @@
var s = jsn.payload.settings || {}; var s = jsn.payload.settings || {};
document.getElementById("notionToken").value = s.notionToken || ""; document.getElementById("notionToken").value = s.notionToken || "";
globalUserId = s.userId || ""; globalUserId = s.userId || "";
if (globalUserId) { if (globalUserId && cachedUsers.length > 0) {
var sel = document.getElementById("userId"); // Users already loaded — re-populate with correct selection
if (sel.querySelector('option[value="' + globalUserId + '"]')) { populateUsers(cachedUsers, globalUserId);
sel.value = globalUserId;
}
} }
credConfigured = !!(s.notionToken && s.userId); credConfigured = !!(s.notionToken && s.userId);

Binary file not shown.

View File

@@ -1,4 +1,4 @@
const CURRENT_VERSION = "1.0.28"; const CURRENT_VERSION = "1.0.29";
const GITEA_BASE = "https://gitea.pdmarf.co.uk/pdm/stream_deck_notion_timer/raw/branch/stable-rebuild"; const GITEA_BASE = "https://gitea.pdmarf.co.uk/pdm/stream_deck_notion_timer/raw/branch/stable-rebuild";
const SIGNING_PUBLIC_KEY = `-----BEGIN PUBLIC KEY----- const SIGNING_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
MCowBQYDK2VwAyEAN7ko8TUpuPzPAJuKAZCRjV0c4ZSlou5d9pUAF6o12b4= MCowBQYDK2VwAyEAN7ko8TUpuPzPAJuKAZCRjV0c4ZSlou5d9pUAF6o12b4=

View File

@@ -1 +1 @@
{ "version": "1.0.28" } { "version": "1.0.29" }