Compare commits

..
2 Commits
Author SHA1 Message Date
pdmarf 45201bc376 v1.0.43: self-heal stale button icon when blocked by the keyDown lock
When a keyDown is blocked by the v1.0.42 lock, redraw that button to
match memRunningActionId instead of leaving whatever it was already
showing. This closes the follow-on issue found while testing 1.0.42:
a button's key image can go stale if its Notion timer was ever
stopped/started outside the plugin (e.g. a manual Notion edit), and
a blocked press was leaving that stale image in place — misleading
the user into thinking a timer was running when it wasn't, which
then caused a *real* unintended timer start on the next press.
2026-08-25 16:27:46 +01:00
pdmarf 18f8007df5 v1.0.42: fix duplicate timer race across different buttons
pendingKeyDown was a Set keyed by action.id, so it only blocked a
button from re-firing itself. Pressing two different buttons in fast
succession (e.g. RB01 then RA01) both passed the guard, both read
memRunningActionId before either had persisted it, and both started
a Notion timer entry. Replaced with a single keyDownBusy flag shared
across all buttons of the action, set synchronously before the first
await, closing the race.
2026-08-25 15:42:43 +01:00
4 changed files with 36 additions and 13 deletions
+13 -5
View File
@@ -6438,7 +6438,7 @@ async function stopTimer(token, entryId) {
}
// src/plugin.ts
var CURRENT_VERSION = "1.0.41";
var CURRENT_VERSION = "1.0.43";
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=
@@ -6587,7 +6587,7 @@ Should it continue?" buttons {"Stop", "Continue"} default button "Continue" givi
}
var TimerToggle = class extends SingletonAction {
projectCache = /* @__PURE__ */ new Map();
pendingKeyDown = /* @__PURE__ */ new Set();
keyDownBusy = false;
elapsedCheckTimer = null;
clearElapsedCheck() {
if (this.elapsedCheckTimer) clearTimeout(this.elapsedCheckTimer);
@@ -6637,8 +6637,16 @@ var TimerToggle = class extends SingletonAction {
await sendProjectsToPI();
}
async onKeyDown(ev) {
if (this.pendingKeyDown.has(ev.action.id)) return;
this.pendingKeyDown.add(ev.action.id);
if (this.keyDownBusy) {
const title = buttonTitle(ev.payload.settings.projectName || "");
const shouldBeRunning = memRunningActionId === ev.action.id;
await Promise.all([
ev.action.setState(shouldBeRunning ? 1 : 0),
ev.action.setTitle(shouldBeRunning ? `\u23F1 ${title}` : title)
]);
return;
}
this.keyDownBusy = true;
try {
const { projectId, projectName } = ev.payload.settings;
const title = buttonTitle(projectName || "");
@@ -6691,7 +6699,7 @@ var TimerToggle = class extends SingletonAction {
await ev.action.showAlert();
}
} finally {
this.pendingKeyDown.delete(ev.action.id);
this.keyDownBusy = false;
}
}
};
@@ -1,2 +1,3 @@
ג /}‚ֿ‘I]�“v¶₪6ִ®[cV”+�הש™>f&6�$
ת¹ת«b;�׀�אר»@פִb}©ע&X
íü„«ÚƒJºh^©A׊[ÈÍ
Ìg»Jµmã
SÙ¹mš']ï´y�j$¬<ÎÇÙÃ5ef «?eó=™y–
+19 -5
View File
@@ -1,4 +1,4 @@
const CURRENT_VERSION = "1.0.41";
const CURRENT_VERSION = "1.0.43";
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=
@@ -182,7 +182,7 @@ async function promptContinue(title: string): Promise<"stop" | "continue" | "tim
@action({ UUID: "com.pdma.notion-timer.toggle" })
class TimerToggle extends SingletonAction<TimerSettings> {
private projectCache = new Map<string, TimerSettings>();
private pendingKeyDown = new Set<string>();
private keyDownBusy = false;
private elapsedCheckTimer: NodeJS.Timeout | null = null;
private clearElapsedCheck(): void {
@@ -240,8 +240,22 @@ class TimerToggle extends SingletonAction<TimerSettings> {
}
async onKeyDown(ev: KeyDownEvent<TimerSettings>): Promise<void> {
if (this.pendingKeyDown.has(ev.action.id)) return;
this.pendingKeyDown.add(ev.action.id);
// Global lock across ALL buttons of this action, not just this one — otherwise
// near-simultaneous presses on two different buttons both read memRunningActionId
// as "nothing running" and both start a timer in Notion.
if (this.keyDownBusy) {
// Blocked press: redraw THIS button to match known truth instead of leaving
// whatever it was already showing (which can be stale from an out-of-band
// Notion edit) — a pure visual correction, no Notion calls.
const title = buttonTitle(ev.payload.settings.projectName || "");
const shouldBeRunning = memRunningActionId === ev.action.id;
await Promise.all([
ev.action.setState(shouldBeRunning ? 1 : 0),
ev.action.setTitle(shouldBeRunning ? `⏱ ${title}` : title),
]);
return;
}
this.keyDownBusy = true;
try {
const { projectId, projectName } = ev.payload.settings;
const title = buttonTitle(projectName || "");
@@ -293,7 +307,7 @@ class TimerToggle extends SingletonAction<TimerSettings> {
await ev.action.showAlert();
}
} finally {
this.pendingKeyDown.delete(ev.action.id);
this.keyDownBusy = false;
}
}
}
+1 -1
View File
@@ -1 +1 @@
{ "version": "1.0.41" }
{ "version": "1.0.43" }