Compare commits

..

14 Commits

Author SHA1 Message Date
pdmarf
51c83f572e Merge branch 'stable-rebuild' 2026-04-24 08:58:47 +01:00
pdmarf
a21e849ea3 Merge branch 'stable-rebuild' 2026-04-24 08:56:40 +01:00
pdmarf
617c8773de Merge branch 'stable-rebuild' 2026-04-24 08:53:19 +01:00
pdmarf
2eb4c8f53a Merge branch 'stable-rebuild' 2026-04-24 08:50:43 +01:00
pdmarf
53c0ae7993 Merge branch 'stable-rebuild' 2026-04-24 08:43:36 +01:00
pdmarf
d9ca28d125 Merge stable-rebuild into master; everything now on master
Install script and auto-updater both point at master. No more
separate branches needed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-24 07:52:00 +01:00
pdmarf
52216495c2 Deploy stable-rebuild v1.0.26 plugin.js to master
Staff on v1.0.25 check master's version.json for updates. Previously
master was on 1.0.22 (< 1.0.25) so the updater always said "already
up to date". Now master serves the stable-rebuild v1.0.26 binary so
staff can self-update via Check for Updates.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-24 07:50:44 +01:00
pdmarf
c06240f03b v1.0.22: refresh projects/users when API token is saved
Previously onPropertyInspectorDidAppear fired once on PI open — if the
token wasn't saved yet (first-time setup), the dropdown stayed empty
forever. Now saving credentials sends a refresh event to the plugin,
which re-fetches and repopulates projects and names immediately.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-23 20:49:33 +01:00
pdmarf
ad776c9aa9 v1.0.21: auto-updater removes legacy SVG icons on update
Staff machines still had idle.svg/running.svg in their installed plugin
folder (Stream Deck merges rather than replaces on reinstall), causing
the old SVGs to shadow the new PNG icons added in v1.0.15. The
auto-updater now explicitly deletes these legacy files when applying an
update.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-23 20:43:24 +01:00
pdmarf
3df4468605 v1.0.20: fix button icons and surface user-fetch errors
- Remove stale idle.svg/running.svg from zip (were shadowing the PNG
  icons added in v1.0.15, causing old grey icons to show instead of
  the Aurora timer images)
- Fix package script to always delete and recreate zip so removed files
  don't persist across builds
- Show a clear error in the name dropdown when fetchUsers fails (e.g.
  Notion integration missing "Read user information" capability)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-23 20:39:51 +01:00
pdmarf
3632300d08 v1.0.19: auto-updater now replaces UI and image assets
Previously only plugin.js was replaced on auto-update, leaving
property-inspector.html, idle.png, and running.png at the originally
installed version. Staff would see the old button colours and missing
UI elements (username dropdown, Update button) even after the code
updated successfully.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-23 20:02:14 +01:00
pdmarf
8d63a6c7c4 v1.0.18
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 18:35:50 +01:00
pdmarf
e34394c1b4 v1.0.17: reload PI after manual update to show new version
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 18:34:29 +01:00
pdmarf
4cfe58cde3 v1.0.16: manual update button in property inspector
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 18:32:11 +01:00
8 changed files with 169 additions and 110 deletions

View File

@@ -6438,7 +6438,7 @@ async function stopTimer(token, entryId) {
} }
// src/plugin.ts // src/plugin.ts
var CURRENT_VERSION = "1.0.39"; var CURRENT_VERSION = "1.0.31";
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=
@@ -6528,17 +6528,17 @@ async function getGlobal() {
return { ...stored, ...HARDCODED }; return { ...stored, ...HARDCODED };
} }
var memRunningEntryId = void 0; var memRunningEntryId = void 0;
var memRunningActionId = void 0; async function getRunningEntryId() {
async function loadRunningState() { if (memRunningEntryId === void 0) {
if (memRunningEntryId !== void 0) return; const stored = await plugin_default.settings.getGlobalSettings();
const stored = await plugin_default.settings.getGlobalSettings(); memRunningEntryId = stored.runningEntryId ?? null;
memRunningEntryId = stored.runningEntryId ?? null; }
memRunningActionId = stored.runningActionId ?? null; return memRunningEntryId;
} }
function setRunningEntry(entryId, actionId) { async function setRunningEntry(entryId) {
memRunningEntryId = entryId; memRunningEntryId = entryId;
memRunningActionId = actionId; const stored = await plugin_default.settings.getGlobalSettings();
plugin_default.settings.getGlobalSettings().then((stored) => plugin_default.settings.setGlobalSettings({ ...stored, runningEntryId: entryId, runningActionId: actionId })).catch((err) => plugin_default.logger.error("Failed to persist running state:", err)); await plugin_default.settings.setGlobalSettings({ ...stored, runningEntryId: entryId });
} }
async function sendProjectsToPI(tokenOverride) { async function sendProjectsToPI(tokenOverride) {
try { try {
@@ -6568,40 +6568,34 @@ function buttonTitle(projectName) {
return projectName.replace(/^[\p{Extended_Pictographic}\uFE0F\s]+/u, "").trim(); return projectName.replace(/^[\p{Extended_Pictographic}\uFE0F\s]+/u, "").trim();
} }
var TimerToggle = class extends SingletonAction { var TimerToggle = class extends SingletonAction {
projectCache = /* @__PURE__ */ new Map(); settingsCache = /* @__PURE__ */ new Map();
async onWillAppear(ev) { async onWillAppear(ev) {
this.projectCache.set(ev.action.id, ev.payload.settings); const { activeEntryId, projectName } = ev.payload.settings;
const title = buttonTitle(ev.payload.settings.projectName || ""); const title = buttonTitle(projectName || "");
await loadRunningState(); const running = await getRunningEntryId();
const isRunning = memRunningActionId === ev.action.id; const isRunning = !!activeEntryId && activeEntryId === running;
if (isRunning) { if (activeEntryId && !isRunning) {
await Promise.all([ev.action.setState(1), ev.action.setTitle(`\u23F1 ${title}`)]); const cleared = { ...ev.payload.settings, activeEntryId: null };
} else { await ev.action.setSettings(cleared);
this.settingsCache.set(ev.action.id, cleared);
await Promise.all([ev.action.setState(0), ev.action.setTitle(title)]); await Promise.all([ev.action.setState(0), ev.action.setTitle(title)]);
} else {
this.settingsCache.set(ev.action.id, ev.payload.settings);
if (isRunning) {
await Promise.all([ev.action.setState(1), ev.action.setTitle(`\u23F1 ${title}`)]);
} else {
await Promise.all([ev.action.setState(0), ev.action.setTitle(title)]);
}
} }
} }
async onPropertyInspectorDidAppear(_ev) { async onPropertyInspectorDidAppear(_ev) {
await sendProjectsToPI(); await sendProjectsToPI();
} }
async onKeyDown(ev) { async onKeyDown(ev) {
const { projectId, projectName } = ev.payload.settings; this.settingsCache.set(ev.action.id, ev.payload.settings);
const title = buttonTitle(projectName || "");
const isRunning = memRunningActionId === ev.action.id;
if (projectId) {
if (isRunning) {
await Promise.all([ev.action.setState(0), ev.action.setTitle(title)]);
} else {
for (const other of this.actions) {
if (other.id === ev.action.id) continue;
if (memRunningActionId === other.id) {
const s = this.projectCache.get(other.id);
await Promise.all([other.setState(0), other.setTitle(buttonTitle(s?.projectName || ""))]);
}
}
await Promise.all([ev.action.setState(1), ev.action.setTitle(`\u23F1 ${title}`)]);
}
}
const global = await getGlobal(); const global = await getGlobal();
const { projectId, projectName, activeEntryId } = ev.payload.settings;
const title = buttonTitle(projectName || "");
if (!isConfigured(global)) { if (!isConfigured(global)) {
await ev.action.showAlert(); await ev.action.showAlert();
return; return;
@@ -6611,23 +6605,51 @@ var TimerToggle = class extends SingletonAction {
return; return;
} }
try { try {
if (isRunning) { if (activeEntryId) {
await stopTimer(global.notionToken, memRunningEntryId); await stopTimer(global.notionToken, activeEntryId);
setRunningEntry(null, null); const stopped = { ...ev.payload.settings, activeEntryId: null };
await Promise.all([ev.action.setState(0), ev.action.setTitle(title)]); await ev.action.setSettings(stopped);
this.settingsCache.set(ev.action.id, stopped);
await ev.action.setState(0);
await ev.action.setTitle(title);
await setRunningEntry(null);
} else { } else {
if (memRunningEntryId) { const prevEntryId = await getRunningEntryId();
await stopTimer(global.notionToken, memRunningEntryId); 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 || ""))]);
}
}
} }
const entryId = await startTimer(global.notionToken, global.timingDbId, projectId, projectName, global.userId);
setRunningEntry(entryId, ev.action.id);
await Promise.all([ev.action.setState(1), ev.action.setTitle(`\u23F1 ${title}`)]); 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) {
if (other.id === ev.action.id) continue;
const otherSettings = this.settingsCache.get(other.id);
if (otherSettings?.activeEntryId === prevEntryId) {
const stopped = { ...otherSettings, activeEntryId: null };
await other.setSettings(stopped);
this.settingsCache.set(other.id, stopped);
}
}
}
const entryId = await startTimer(
global.notionToken,
global.timingDbId,
projectId,
projectName,
global.userId
);
const started = { ...ev.payload.settings, activeEntryId: entryId };
await ev.action.setSettings(started);
this.settingsCache.set(ev.action.id, started);
await setRunningEntry(entryId);
} }
} catch (err) { } catch (err) {
await Promise.all([
ev.action.setState(isRunning ? 1 : 0),
ev.action.setTitle(isRunning ? `\u23F1 ${title}` : title)
]);
plugin_default.logger.error("Timer toggle failed:", err); plugin_default.logger.error("Timer toggle failed:", err);
await ev.action.showAlert(); await ev.action.showAlert();
} }

View File

@@ -1 +1 @@
в<╥!Ъ░xR√з└С;=▀LI" я╓╢HuэF├ы▐Ос─╒┘ sb▌Y╛{йH│╤Н.JщNЦь1╔l XCá¹kf*j”˜vèk𮂿

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.39", "Version": "1.0.31",
"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

@@ -7,7 +7,7 @@ TMP_DIR=$(mktemp -d)
PLUGIN_FILE="${TMP_DIR}/notion-timer.streamDeckPlugin" PLUGIN_FILE="${TMP_DIR}/notion-timer.streamDeckPlugin"
echo "Downloading Notion Timer..." echo "Downloading Notion Timer..."
curl -sL "${GITEA}/${REPO}/raw/branch/stable-rebuild/notion-timer.streamDeckPlugin" -o "${PLUGIN_FILE}" curl -sL "${GITEA}/${REPO}/raw/branch/master/notion-timer.streamDeckPlugin" -o "${PLUGIN_FILE}"
echo "Installing — Stream Deck will open automatically..." echo "Installing — Stream Deck will open automatically..."
open "${PLUGIN_FILE}" open "${PLUGIN_FILE}"

Binary file not shown.

View File

@@ -4,7 +4,7 @@
"description": "Notion time tracking toggle for Stream Deck", "description": "Notion time tracking toggle for Stream Deck",
"scripts": { "scripts": {
"build": "esbuild src/plugin.ts --bundle --platform=node --target=node20 --outfile=com.pdma.notion-timer.sdPlugin/bin/plugin.js --external:electron && node scripts/sign.js", "build": "esbuild src/plugin.ts --bundle --platform=node --target=node20 --outfile=com.pdma.notion-timer.sdPlugin/bin/plugin.js --external:electron && node scripts/sign.js",
"package": "npm run build && zip -r notion-timer.streamDeckPlugin com.pdma.notion-timer.sdPlugin && echo 'Packaged: notion-timer.streamDeckPlugin'", "package": "npm run build && rm -f notion-timer.streamDeckPlugin && zip -r notion-timer.streamDeckPlugin com.pdma.notion-timer.sdPlugin && echo 'Packaged: notion-timer.streamDeckPlugin'",
"dev": "esbuild src/plugin.ts --bundle --platform=node --target=node20 --outfile=com.pdma.notion-timer.sdPlugin/bin/plugin.js --external:electron --watch", "dev": "esbuild src/plugin.ts --bundle --platform=node --target=node20 --outfile=com.pdma.notion-timer.sdPlugin/bin/plugin.js --external:electron --watch",
"sign": "node scripts/sign.js", "sign": "node scripts/sign.js",
"link": "ln -sf \"$(pwd)/com.pdma.notion-timer.sdPlugin\" \"$HOME/Library/Application Support/com.elgato.StreamDeck/Plugins/com.pdma.notion-timer.sdPlugin\"", "link": "ln -sf \"$(pwd)/com.pdma.notion-timer.sdPlugin\" \"$HOME/Library/Application Support/com.elgato.StreamDeck/Plugins/com.pdma.notion-timer.sdPlugin\"",

View File

@@ -1,4 +1,4 @@
const CURRENT_VERSION = "1.0.39"; const CURRENT_VERSION = "1.0.31";
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=
@@ -52,6 +52,7 @@ async function checkForUpdates(sendStatus?: (msg: string) => void): Promise<void
const path = await import("path"); const path = await import("path");
const pluginRoot = path.join(path.dirname(__filename), ".."); const pluginRoot = path.join(path.dirname(__filename), "..");
// Update UI and image assets
const ASSETS = [ const ASSETS = [
"ui/property-inspector.html", "ui/property-inspector.html",
"ui/global-property-inspector.html", "ui/global-property-inspector.html",
@@ -66,6 +67,7 @@ async function checkForUpdates(sendStatus?: (msg: string) => void): Promise<void
} }
} }
// Remove legacy SVG icons that persist on disk after Stream Deck merge-installs
const LEGACY = ["imgs/idle.svg", "imgs/running.svg"]; const LEGACY = ["imgs/idle.svg", "imgs/running.svg"];
for (const f of LEGACY) { for (const f of LEGACY) {
try { fs.unlinkSync(path.join(pluginRoot, f)); } catch { /* already gone */ } try { fs.unlinkSync(path.join(pluginRoot, f)); } catch { /* already gone */ }
@@ -96,12 +98,12 @@ interface GlobalSettings {
projectsDbId: string; projectsDbId: string;
userId: string; userId: string;
runningEntryId?: string | null; runningEntryId?: string | null;
runningActionId?: string | null;
} }
interface TimerSettings { interface TimerSettings {
projectId: string; projectId: string;
projectName: string; projectName: string;
activeEntryId: string | null;
} }
const HARDCODED = { const HARDCODED = {
@@ -114,24 +116,21 @@ async function getGlobal(): Promise<GlobalSettings> {
return { ...stored, ...HARDCODED }; return { ...stored, ...HARDCODED };
} }
// In-memory running state — avoids async round-trips on every button press // In-memory cache so onWillAppear can check running state without an async round-trip
let memRunningEntryId: string | null | undefined = undefined; let memRunningEntryId: string | null | undefined = undefined; // undefined = not yet loaded
let memRunningActionId: string | null | undefined = undefined;
async function loadRunningState(): Promise<void> { async function getRunningEntryId(): Promise<string | null> {
if (memRunningEntryId !== undefined) return; if (memRunningEntryId === undefined) {
const stored = await streamDeck.settings.getGlobalSettings<GlobalSettings>(); const stored = await streamDeck.settings.getGlobalSettings<GlobalSettings>();
memRunningEntryId = stored.runningEntryId ?? null; memRunningEntryId = stored.runningEntryId ?? null;
memRunningActionId = stored.runningActionId ?? null; }
return memRunningEntryId;
} }
function setRunningEntry(entryId: string | null, actionId: string | null): void { async function setRunningEntry(entryId: string | null): Promise<void> {
memRunningEntryId = entryId; memRunningEntryId = entryId;
memRunningActionId = actionId; const stored = await streamDeck.settings.getGlobalSettings<GlobalSettings>();
// Persist in background — do not await, so the visual is never blocked await streamDeck.settings.setGlobalSettings({ ...stored, runningEntryId: entryId });
streamDeck.settings.getGlobalSettings<GlobalSettings>()
.then(stored => streamDeck.settings.setGlobalSettings({ ...stored, runningEntryId: entryId, runningActionId: actionId }))
.catch(err => streamDeck.logger.error("Failed to persist running state:", err));
} }
async function sendProjectsToPI(tokenOverride?: string): Promise<void> { async function sendProjectsToPI(tokenOverride?: string): Promise<void> {
@@ -160,23 +159,36 @@ function isConfigured(g: GlobalSettings): boolean {
return !!(g.notionToken && g.userId); return !!(g.notionToken && g.userId);
} }
// Strip leading emoji characters so the button title shows just the project name
function buttonTitle(projectName: string): string { function buttonTitle(projectName: string): string {
return projectName.replace(/^[\p{Extended_Pictographic}\uFE0F\s]+/u, "").trim(); return projectName.replace(/^[\p{Extended_Pictographic}\uFE0F\s]+/u, "").trim();
} }
@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 settingsCache = new Map<string, TimerSettings>();
async onWillAppear(ev: WillAppearEvent<TimerSettings>): Promise<void> { async onWillAppear(ev: WillAppearEvent<TimerSettings>): Promise<void> {
this.projectCache.set(ev.action.id, ev.payload.settings); const { activeEntryId, projectName } = ev.payload.settings;
const title = buttonTitle(ev.payload.settings.projectName || ""); const title = buttonTitle(projectName || "");
await loadRunningState();
const isRunning = memRunningActionId === ev.action.id; // Use in-memory cache to determine correct state before rendering — no flash
if (isRunning) { const running = await getRunningEntryId();
await Promise.all([ev.action.setState(1), ev.action.setTitle(`${title}`)]); const isRunning = !!activeEntryId && activeEntryId === running;
} else {
if (activeEntryId && !isRunning) {
// Self-heal: this button thinks it's running but it's not — clear it
const cleared = { ...ev.payload.settings, activeEntryId: null };
await ev.action.setSettings(cleared);
this.settingsCache.set(ev.action.id, cleared);
await Promise.all([ev.action.setState(0), ev.action.setTitle(title)]); await Promise.all([ev.action.setState(0), ev.action.setTitle(title)]);
} else {
this.settingsCache.set(ev.action.id, ev.payload.settings);
if (isRunning) {
await Promise.all([ev.action.setState(1), ev.action.setTitle(`${title}`)]);
} else {
await Promise.all([ev.action.setState(0), ev.action.setTitle(title)]);
}
} }
} }
@@ -185,49 +197,72 @@ class TimerToggle extends SingletonAction<TimerSettings> {
} }
async onKeyDown(ev: KeyDownEvent<TimerSettings>): Promise<void> { async onKeyDown(ev: KeyDownEvent<TimerSettings>): Promise<void> {
const { projectId, projectName } = ev.payload.settings; this.settingsCache.set(ev.action.id, ev.payload.settings);
const global = await getGlobal();
const { projectId, projectName, activeEntryId } = ev.payload.settings;
const title = buttonTitle(projectName || ""); const title = buttonTitle(projectName || "");
const isRunning = memRunningActionId === ev.action.id;
// Instant visual feedback — no setSettings, no flash if (!isConfigured(global)) {
if (projectId) { await ev.action.showAlert();
if (isRunning) { return;
await Promise.all([ev.action.setState(0), ev.action.setTitle(title)]); }
if (!projectId) {
await ev.action.showAlert();
return;
}
try {
if (activeEntryId) {
await stopTimer(global.notionToken, activeEntryId);
const stopped = { ...ev.payload.settings, activeEntryId: null };
await ev.action.setSettings(stopped);
this.settingsCache.set(ev.action.id, stopped);
await ev.action.setState(0);
await ev.action.setTitle(title);
await setRunningEntry(null);
} else { } else {
for (const other of this.actions) { const prevEntryId = await getRunningEntryId();
if (other.id === ev.action.id) continue;
if (memRunningActionId === other.id) { // Optimistically update visuals immediately — no waiting for API
const s = this.projectCache.get(other.id); if (prevEntryId) {
await Promise.all([other.setState(0), other.setTitle(buttonTitle(s?.projectName || ""))]); 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(`${title}`)]); await Promise.all([ev.action.setState(1), ev.action.setTitle(`${title}`)]);
}
}
const global = await getGlobal(); // Now do the API calls
if (!isConfigured(global)) { await ev.action.showAlert(); return; } if (prevEntryId) {
if (!projectId) { await ev.action.showAlert(); return; } await stopTimer(global.notionToken, prevEntryId);
for (const other of this.actions) {
try { if (other.id === ev.action.id) continue;
if (isRunning) { const otherSettings = this.settingsCache.get(other.id);
await stopTimer(global.notionToken, memRunningEntryId!); if (otherSettings?.activeEntryId === prevEntryId) {
setRunningEntry(null, null); const stopped = { ...otherSettings, activeEntryId: null };
await Promise.all([ev.action.setState(0), ev.action.setTitle(title)]); await other.setSettings(stopped);
} else { this.settingsCache.set(other.id, stopped);
if (memRunningEntryId) { }
await stopTimer(global.notionToken, memRunningEntryId); }
} }
const entryId = await startTimer(global.notionToken, global.timingDbId, projectId, projectName, global.userId);
setRunningEntry(entryId, ev.action.id); const entryId = await startTimer(
await Promise.all([ev.action.setState(1), ev.action.setTitle(`${title}`)]); global.notionToken,
global.timingDbId,
projectId,
projectName,
global.userId,
);
const started = { ...ev.payload.settings, activeEntryId: entryId };
await ev.action.setSettings(started);
this.settingsCache.set(ev.action.id, started);
await setRunningEntry(entryId);
} }
} catch (err) { } catch (err) {
// Revert visual on error
await Promise.all([
ev.action.setState(isRunning ? 1 : 0),
ev.action.setTitle(isRunning ? `${title}` : title),
]);
streamDeck.logger.error("Timer toggle failed:", err); streamDeck.logger.error("Timer toggle failed:", err);
await ev.action.showAlert(); await ev.action.showAlert();
} }
@@ -237,6 +272,7 @@ class TimerToggle extends SingletonAction<TimerSettings> {
const timerAction = new TimerToggle(); const timerAction = new TimerToggle();
streamDeck.actions.registerAction(timerAction); streamDeck.actions.registerAction(timerAction);
// v2 requires using streamDeck.ui.onSendToPlugin — the SingletonAction method does not fire
streamDeck.ui.onSendToPlugin<{ event: string; settings?: TimerSettings; token?: string }>(async (ev) => { streamDeck.ui.onSendToPlugin<{ event: string; settings?: TimerSettings; token?: string }>(async (ev) => {
if (ev.payload.event === "saveSettings" && ev.payload.settings) { if (ev.payload.event === "saveSettings" && ev.payload.settings) {
await ev.action.setSettings(ev.payload.settings); await ev.action.setSettings(ev.payload.settings);
@@ -255,4 +291,5 @@ streamDeck.ui.onSendToPlugin<{ event: string; settings?: TimerSettings; token?:
streamDeck.connect(); streamDeck.connect();
// Check for updates 10 seconds after startup to avoid disrupting initial connection
setTimeout(() => checkForUpdates(), 10_000); setTimeout(() => checkForUpdates(), 10_000);

View File

@@ -1 +1 @@
{ "version": "1.0.39" } { "version": "1.0.31" }