v1.0.26: eliminate double-green flash when switching timers

Both buttons now flip to their final visual state immediately on key
press, before any API calls. Previously the old button stayed green
throughout the stopTimer network round-trip (~0.5–2s), causing a
window where both buttons appeared green simultaneously.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
pdmarf
2026-04-24 07:47:32 +01:00
parent 47d8c7d98d
commit d6d695e6c0
5 changed files with 28 additions and 15 deletions

View File

@@ -6438,7 +6438,7 @@ async function stopTimer(token, entryId) {
}
// src/plugin.ts
var CURRENT_VERSION = "1.0.25";
var CURRENT_VERSION = "1.0.26";
var GITEA_BASE = "https://gitea.pdmarf.co.uk/pdm/stream_deck_notion_timer/raw/branch/master";
var SIGNING_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
MCowBQYDK2VwAyEAN7ko8TUpuPzPAJuKAZCRjV0c4ZSlou5d9pUAF6o12b4=
@@ -6589,6 +6589,16 @@ var TimerToggle = class extends SingletonAction {
await setRunningEntry(null);
} else {
const prevEntryId = await getRunningEntryId();
if (prevEntryId) {
for (const other of this.actions) {
if (other.id === ev.action.id) continue;
const otherSettings = this.settingsCache.get(other.id);
if (otherSettings?.activeEntryId === prevEntryId) {
await Promise.all([other.setState(0), other.setTitle(buttonTitle(otherSettings.projectName || ""))]);
}
}
}
await Promise.all([ev.action.setState(1), ev.action.setTitle(`\u23F1 ${title}`)]);
if (prevEntryId) {
await stopTimer(global.notionToken, prevEntryId);
for (const other of this.actions) {
@@ -6598,8 +6608,6 @@ var TimerToggle = class extends SingletonAction {
const stopped = { ...otherSettings, activeEntryId: null };
await other.setSettings(stopped);
this.settingsCache.set(other.id, stopped);
await other.setState(0);
await other.setTitle(buttonTitle(otherSettings.projectName || ""));
}
}
}
@@ -6614,8 +6622,6 @@ var TimerToggle = class extends SingletonAction {
await ev.action.setSettings(started);
this.settingsCache.set(ev.action.id, started);
await setRunningEntry(entryId);
await ev.action.setState(1);
await ev.action.setTitle(`\u23F1 ${title}`);
}
} catch (err) {
plugin_default.logger.error("Timer toggle failed:", err);

View File

@@ -1,3 +1,2 @@
чжр╨
HJК{lн И▐>ь┘0^Уt<fх▄╦┼Ь╢\ME
/куCБ╡ЗsW
KHYƢRK>q2lĚűZ­
e>ÓřťőüW%"YŔ8gĆe<C486>€Ý8BÓŻ$>ŤWĎ=kIÜÇÄŹ¸Mîe2K

View File

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