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.
This commit is contained in:
@@ -6438,7 +6438,7 @@ async function stopTimer(token, entryId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// src/plugin.ts
|
// src/plugin.ts
|
||||||
var CURRENT_VERSION = "1.0.41";
|
var CURRENT_VERSION = "1.0.42";
|
||||||
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=
|
||||||
@@ -6587,7 +6587,7 @@ Should it continue?" buttons {"Stop", "Continue"} default button "Continue" givi
|
|||||||
}
|
}
|
||||||
var TimerToggle = class extends SingletonAction {
|
var TimerToggle = class extends SingletonAction {
|
||||||
projectCache = /* @__PURE__ */ new Map();
|
projectCache = /* @__PURE__ */ new Map();
|
||||||
pendingKeyDown = /* @__PURE__ */ new Set();
|
keyDownBusy = false;
|
||||||
elapsedCheckTimer = null;
|
elapsedCheckTimer = null;
|
||||||
clearElapsedCheck() {
|
clearElapsedCheck() {
|
||||||
if (this.elapsedCheckTimer) clearTimeout(this.elapsedCheckTimer);
|
if (this.elapsedCheckTimer) clearTimeout(this.elapsedCheckTimer);
|
||||||
@@ -6637,8 +6637,8 @@ var TimerToggle = class extends SingletonAction {
|
|||||||
await sendProjectsToPI();
|
await sendProjectsToPI();
|
||||||
}
|
}
|
||||||
async onKeyDown(ev) {
|
async onKeyDown(ev) {
|
||||||
if (this.pendingKeyDown.has(ev.action.id)) return;
|
if (this.keyDownBusy) return;
|
||||||
this.pendingKeyDown.add(ev.action.id);
|
this.keyDownBusy = true;
|
||||||
try {
|
try {
|
||||||
const { projectId, projectName } = ev.payload.settings;
|
const { projectId, projectName } = ev.payload.settings;
|
||||||
const title = buttonTitle(projectName || "");
|
const title = buttonTitle(projectName || "");
|
||||||
@@ -6691,7 +6691,7 @@ var TimerToggle = class extends SingletonAction {
|
|||||||
await ev.action.showAlert();
|
await ev.action.showAlert();
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
this.pendingKeyDown.delete(ev.action.id);
|
this.keyDownBusy = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
ג /}‚ֿ‘I]�“v¶₪6ִ®[cV”+�הש™>f&6�$
|
HeÒ¾à�¡21™ßC'Ý—ÿ9ƒx¤,$2&úöö¡rÅYËb’L¸ËeìÉ.ËQ:¶þõub;B™¢&
|
||||||
ת¹ת«b;�׀�אר»@פִb}©ע&X ␍
|
|
||||||
+8
-5
@@ -1,4 +1,4 @@
|
|||||||
const CURRENT_VERSION = "1.0.41";
|
const CURRENT_VERSION = "1.0.42";
|
||||||
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=
|
||||||
@@ -182,7 +182,7 @@ async function promptContinue(title: string): Promise<"stop" | "continue" | "tim
|
|||||||
@action({ UUID: "com.pdma.notion-timer.toggle" })
|
@action({ UUID: "com.pdma.notion-timer.toggle" })
|
||||||
class TimerToggle extends SingletonAction<TimerSettings> {
|
class TimerToggle extends SingletonAction<TimerSettings> {
|
||||||
private projectCache = new Map<string, TimerSettings>();
|
private projectCache = new Map<string, TimerSettings>();
|
||||||
private pendingKeyDown = new Set<string>();
|
private keyDownBusy = false;
|
||||||
private elapsedCheckTimer: NodeJS.Timeout | null = null;
|
private elapsedCheckTimer: NodeJS.Timeout | null = null;
|
||||||
|
|
||||||
private clearElapsedCheck(): void {
|
private clearElapsedCheck(): void {
|
||||||
@@ -240,8 +240,11 @@ class TimerToggle extends SingletonAction<TimerSettings> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async onKeyDown(ev: KeyDownEvent<TimerSettings>): Promise<void> {
|
async onKeyDown(ev: KeyDownEvent<TimerSettings>): Promise<void> {
|
||||||
if (this.pendingKeyDown.has(ev.action.id)) return;
|
// Global lock across ALL buttons of this action, not just this one — otherwise
|
||||||
this.pendingKeyDown.add(ev.action.id);
|
// near-simultaneous presses on two different buttons both read memRunningActionId
|
||||||
|
// as "nothing running" and both start a timer in Notion.
|
||||||
|
if (this.keyDownBusy) return;
|
||||||
|
this.keyDownBusy = true;
|
||||||
try {
|
try {
|
||||||
const { projectId, projectName } = ev.payload.settings;
|
const { projectId, projectName } = ev.payload.settings;
|
||||||
const title = buttonTitle(projectName || "");
|
const title = buttonTitle(projectName || "");
|
||||||
@@ -293,7 +296,7 @@ class TimerToggle extends SingletonAction<TimerSettings> {
|
|||||||
await ev.action.showAlert();
|
await ev.action.showAlert();
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
this.pendingKeyDown.delete(ev.action.id);
|
this.keyDownBusy = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
{ "version": "1.0.41" }
|
{ "version": "1.0.42" }
|
||||||
|
|||||||
Reference in New Issue
Block a user