Compare commits
21 Commits
stable-reb
...
1294688b40
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1294688b40 | ||
|
|
9b62d55dbe | ||
|
|
0eeeed270f | ||
|
|
49e939c137 | ||
|
|
7e66939fdb | ||
|
|
ea15f72215 | ||
|
|
e493c19cc8 | ||
|
|
51c83f572e | ||
|
|
a21e849ea3 | ||
|
|
617c8773de | ||
|
|
2eb4c8f53a | ||
|
|
53c0ae7993 | ||
|
|
d9ca28d125 | ||
|
|
52216495c2 | ||
|
|
c06240f03b | ||
|
|
ad776c9aa9 | ||
|
|
3df4468605 | ||
|
|
3632300d08 | ||
|
|
8d63a6c7c4 | ||
|
|
e34394c1b4 | ||
|
|
4cfe58cde3 |
@@ -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.38";
|
||||||
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=
|
||||||
@@ -6535,10 +6535,11 @@ async function loadRunningState() {
|
|||||||
memRunningEntryId = stored.runningEntryId ?? null;
|
memRunningEntryId = stored.runningEntryId ?? null;
|
||||||
memRunningActionId = stored.runningActionId ?? null;
|
memRunningActionId = stored.runningActionId ?? null;
|
||||||
}
|
}
|
||||||
function setRunningEntry(entryId, actionId) {
|
async function setRunningEntry(entryId, actionId) {
|
||||||
memRunningEntryId = entryId;
|
memRunningEntryId = entryId;
|
||||||
memRunningActionId = actionId;
|
memRunningActionId = actionId;
|
||||||
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));
|
const stored = await plugin_default.settings.getGlobalSettings();
|
||||||
|
await plugin_default.settings.setGlobalSettings({ ...stored, runningEntryId: entryId, runningActionId: actionId });
|
||||||
}
|
}
|
||||||
async function sendProjectsToPI(tokenOverride) {
|
async function sendProjectsToPI(tokenOverride) {
|
||||||
try {
|
try {
|
||||||
@@ -6567,61 +6568,8 @@ function isConfigured(g) {
|
|||||||
function buttonTitle(projectName) {
|
function buttonTitle(projectName) {
|
||||||
return projectName.replace(/^[\p{Extended_Pictographic}\uFE0F\s]+/u, "").trim();
|
return projectName.replace(/^[\p{Extended_Pictographic}\uFE0F\s]+/u, "").trim();
|
||||||
}
|
}
|
||||||
var ELAPSED_CHECK_MS = 60 * 60 * 1e3;
|
|
||||||
var DIALOG_TIMEOUT_SECONDS = 300;
|
|
||||||
async function promptContinue(title) {
|
|
||||||
const { execFile: execFile3 } = await import("node:child_process");
|
|
||||||
const safeTitle = title.replace(/[\\"]/g, "");
|
|
||||||
const script = `display dialog "Timer for ${safeTitle} has been running for over an hour.
|
|
||||||
|
|
||||||
Should it continue?" buttons {"Stop", "Continue"} default button "Continue" giving up after ${DIALOG_TIMEOUT_SECONDS}`;
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
execFile3("osascript", ["-e", script], (err, stdout) => {
|
|
||||||
if (err || /gave up:true/.test(String(stdout))) {
|
|
||||||
resolve("timeout");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
resolve(/button returned:Stop/.test(String(stdout)) ? "stop" : "continue");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
var TimerToggle = class extends SingletonAction {
|
var TimerToggle = class extends SingletonAction {
|
||||||
projectCache = /* @__PURE__ */ new Map();
|
projectCache = /* @__PURE__ */ new Map();
|
||||||
pendingKeyDown = /* @__PURE__ */ new Set();
|
|
||||||
elapsedCheckTimer = null;
|
|
||||||
clearElapsedCheck() {
|
|
||||||
if (this.elapsedCheckTimer) clearTimeout(this.elapsedCheckTimer);
|
|
||||||
this.elapsedCheckTimer = null;
|
|
||||||
}
|
|
||||||
scheduleElapsedCheck(entryId, actionId, title) {
|
|
||||||
this.clearElapsedCheck();
|
|
||||||
this.elapsedCheckTimer = setTimeout(() => {
|
|
||||||
this.checkElapsed(entryId, actionId, title);
|
|
||||||
}, ELAPSED_CHECK_MS);
|
|
||||||
}
|
|
||||||
async checkElapsed(entryId, actionId, title) {
|
|
||||||
if (memRunningEntryId !== entryId) return;
|
|
||||||
const answer = await promptContinue(title);
|
|
||||||
if (memRunningEntryId !== entryId) return;
|
|
||||||
if (answer === "continue") {
|
|
||||||
this.scheduleElapsedCheck(entryId, actionId, title);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const global = await getGlobal();
|
|
||||||
await stopTimer(global.notionToken, entryId);
|
|
||||||
} catch (err) {
|
|
||||||
plugin_default.logger.error("Auto-stop after elapsed-check failed:", err);
|
|
||||||
}
|
|
||||||
setRunningEntry(null, null);
|
|
||||||
this.clearElapsedCheck();
|
|
||||||
for (const action2 of this.actions) {
|
|
||||||
if (action2.id === actionId) {
|
|
||||||
await Promise.all([action2.setState(0), action2.setTitle(title)]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async onWillAppear(ev) {
|
async onWillAppear(ev) {
|
||||||
this.projectCache.set(ev.action.id, ev.payload.settings);
|
this.projectCache.set(ev.action.id, ev.payload.settings);
|
||||||
const title = buttonTitle(ev.payload.settings.projectName || "");
|
const title = buttonTitle(ev.payload.settings.projectName || "");
|
||||||
@@ -6637,9 +6585,6 @@ var TimerToggle = class extends SingletonAction {
|
|||||||
await sendProjectsToPI();
|
await sendProjectsToPI();
|
||||||
}
|
}
|
||||||
async onKeyDown(ev) {
|
async onKeyDown(ev) {
|
||||||
if (this.pendingKeyDown.has(ev.action.id)) return;
|
|
||||||
this.pendingKeyDown.add(ev.action.id);
|
|
||||||
try {
|
|
||||||
const { projectId, projectName } = ev.payload.settings;
|
const { projectId, projectName } = ev.payload.settings;
|
||||||
const title = buttonTitle(projectName || "");
|
const title = buttonTitle(projectName || "");
|
||||||
const isRunning = memRunningActionId === ev.action.id;
|
const isRunning = memRunningActionId === ev.action.id;
|
||||||
@@ -6669,18 +6614,13 @@ var TimerToggle = class extends SingletonAction {
|
|||||||
try {
|
try {
|
||||||
if (isRunning) {
|
if (isRunning) {
|
||||||
await stopTimer(global.notionToken, memRunningEntryId);
|
await stopTimer(global.notionToken, memRunningEntryId);
|
||||||
setRunningEntry(null, null);
|
await setRunningEntry(null, null);
|
||||||
this.clearElapsedCheck();
|
|
||||||
await Promise.all([ev.action.setState(0), ev.action.setTitle(title)]);
|
|
||||||
} else {
|
} else {
|
||||||
if (memRunningEntryId) {
|
if (memRunningEntryId) {
|
||||||
await stopTimer(global.notionToken, memRunningEntryId);
|
await stopTimer(global.notionToken, memRunningEntryId);
|
||||||
this.clearElapsedCheck();
|
|
||||||
}
|
}
|
||||||
const entryId = await startTimer(global.notionToken, global.timingDbId, projectId, projectName, global.userId);
|
const entryId = await startTimer(global.notionToken, global.timingDbId, projectId, projectName, global.userId);
|
||||||
setRunningEntry(entryId, ev.action.id);
|
await setRunningEntry(entryId, ev.action.id);
|
||||||
this.scheduleElapsedCheck(entryId, ev.action.id, title);
|
|
||||||
await Promise.all([ev.action.setState(1), ev.action.setTitle(`\u23F1 ${title}`)]);
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
@@ -6690,9 +6630,6 @@ var TimerToggle = class extends SingletonAction {
|
|||||||
plugin_default.logger.error("Timer toggle failed:", err);
|
plugin_default.logger.error("Timer toggle failed:", err);
|
||||||
await ev.action.showAlert();
|
await ev.action.showAlert();
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
this.pendingKeyDown.delete(ev.action.id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
TimerToggle = __decorateClass([
|
TimerToggle = __decorateClass([
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
ג /}‚ֿ‘I]<5D>“v¶₪6ִ®[cV”+<2B>הש™>f&6<>$
|
Κ¤<06>C¤•Sί¤
|
||||||
ת¹ת«b;<3B>׀<EFBFBD>אר»@פִb}©ע&X
|
Φ®Έ}•~P}ηΜ<>Z;·ΆxΤη{,¦NYPπu4#ΑΚ„jα§ΎWCκΈ©σΔ«Έ<0E>d
|
||||||
@@ -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.38",
|
||||||
"SDKVersion": 2,
|
"SDKVersion": 2,
|
||||||
"Software": { "MinimumVersion": "5.0" },
|
"Software": { "MinimumVersion": "5.0" },
|
||||||
"OS": [{ "Platform": "mac", "MinimumVersion": "10.11" }],
|
"OS": [{ "Platform": "mac", "MinimumVersion": "10.11" }],
|
||||||
|
|||||||
@@ -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.
@@ -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\"",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const CURRENT_VERSION = "1.0.41";
|
const CURRENT_VERSION = "1.0.38";
|
||||||
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=
|
||||||
@@ -125,13 +125,11 @@ async function loadRunningState(): Promise<void> {
|
|||||||
memRunningActionId = stored.runningActionId ?? null;
|
memRunningActionId = stored.runningActionId ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setRunningEntry(entryId: string | null, actionId: string | null): void {
|
async function setRunningEntry(entryId: string | null, actionId: string | null): Promise<void> {
|
||||||
memRunningEntryId = entryId;
|
memRunningEntryId = entryId;
|
||||||
memRunningActionId = actionId;
|
memRunningActionId = actionId;
|
||||||
// Persist in background — do not await, so the visual is never blocked
|
const stored = await streamDeck.settings.getGlobalSettings<GlobalSettings>();
|
||||||
streamDeck.settings.getGlobalSettings<GlobalSettings>()
|
await streamDeck.settings.setGlobalSettings({ ...stored, runningEntryId: entryId, runningActionId: actionId });
|
||||||
.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> {
|
||||||
@@ -164,64 +162,9 @@ 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
const ELAPSED_CHECK_MS = 60 * 60 * 1000; // 1 hour
|
|
||||||
const DIALOG_TIMEOUT_SECONDS = 300; // 5 minutes
|
|
||||||
|
|
||||||
async function promptContinue(title: string): Promise<"stop" | "continue" | "timeout"> {
|
|
||||||
const { execFile } = await import("node:child_process");
|
|
||||||
const safeTitle = title.replace(/[\\"]/g, "");
|
|
||||||
const script = `display dialog "Timer for ${safeTitle} has been running for over an hour.\n\nShould it continue?" buttons {"Stop", "Continue"} default button "Continue" giving up after ${DIALOG_TIMEOUT_SECONDS}`;
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
execFile("osascript", ["-e", script], (err, stdout) => {
|
|
||||||
if (err || /gave up:true/.test(String(stdout))) { resolve("timeout"); return; }
|
|
||||||
resolve(/button returned:Stop/.test(String(stdout)) ? "stop" : "continue");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@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 elapsedCheckTimer: NodeJS.Timeout | null = null;
|
|
||||||
|
|
||||||
private clearElapsedCheck(): void {
|
|
||||||
if (this.elapsedCheckTimer) clearTimeout(this.elapsedCheckTimer);
|
|
||||||
this.elapsedCheckTimer = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private scheduleElapsedCheck(entryId: string, actionId: string, title: string): void {
|
|
||||||
this.clearElapsedCheck();
|
|
||||||
this.elapsedCheckTimer = setTimeout(() => {
|
|
||||||
this.checkElapsed(entryId, actionId, title);
|
|
||||||
}, ELAPSED_CHECK_MS);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async checkElapsed(entryId: string, actionId: string, title: string): Promise<void> {
|
|
||||||
if (memRunningEntryId !== entryId) return;
|
|
||||||
const answer = await promptContinue(title);
|
|
||||||
if (memRunningEntryId !== entryId) return;
|
|
||||||
|
|
||||||
if (answer === "continue") {
|
|
||||||
this.scheduleElapsedCheck(entryId, actionId, title);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const global = await getGlobal();
|
|
||||||
await stopTimer(global.notionToken, entryId);
|
|
||||||
} catch (err) {
|
|
||||||
streamDeck.logger.error("Auto-stop after elapsed-check failed:", err);
|
|
||||||
}
|
|
||||||
setRunningEntry(null, null);
|
|
||||||
this.clearElapsedCheck();
|
|
||||||
for (const action of this.actions) {
|
|
||||||
if (action.id === actionId) {
|
|
||||||
await Promise.all([action.setState(0), action.setTitle(title)]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async onWillAppear(ev: WillAppearEvent<TimerSettings>): Promise<void> {
|
async onWillAppear(ev: WillAppearEvent<TimerSettings>): Promise<void> {
|
||||||
this.projectCache.set(ev.action.id, ev.payload.settings);
|
this.projectCache.set(ev.action.id, ev.payload.settings);
|
||||||
@@ -240,9 +183,6 @@ 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;
|
|
||||||
this.pendingKeyDown.add(ev.action.id);
|
|
||||||
try {
|
|
||||||
const { projectId, projectName } = ev.payload.settings;
|
const { projectId, projectName } = ev.payload.settings;
|
||||||
const title = buttonTitle(projectName || "");
|
const title = buttonTitle(projectName || "");
|
||||||
const isRunning = memRunningActionId === ev.action.id;
|
const isRunning = memRunningActionId === ev.action.id;
|
||||||
@@ -270,18 +210,13 @@ class TimerToggle extends SingletonAction<TimerSettings> {
|
|||||||
try {
|
try {
|
||||||
if (isRunning) {
|
if (isRunning) {
|
||||||
await stopTimer(global.notionToken, memRunningEntryId!);
|
await stopTimer(global.notionToken, memRunningEntryId!);
|
||||||
setRunningEntry(null, null);
|
await setRunningEntry(null, null);
|
||||||
this.clearElapsedCheck();
|
|
||||||
await Promise.all([ev.action.setState(0), ev.action.setTitle(title)]);
|
|
||||||
} else {
|
} else {
|
||||||
if (memRunningEntryId) {
|
if (memRunningEntryId) {
|
||||||
await stopTimer(global.notionToken, memRunningEntryId);
|
await stopTimer(global.notionToken, memRunningEntryId);
|
||||||
this.clearElapsedCheck();
|
|
||||||
}
|
}
|
||||||
const entryId = await startTimer(global.notionToken, global.timingDbId, projectId, projectName, global.userId);
|
const entryId = await startTimer(global.notionToken, global.timingDbId, projectId, projectName, global.userId);
|
||||||
setRunningEntry(entryId, ev.action.id);
|
await setRunningEntry(entryId, ev.action.id);
|
||||||
this.scheduleElapsedCheck(entryId, ev.action.id, title);
|
|
||||||
await Promise.all([ev.action.setState(1), ev.action.setTitle(`⏱ ${title}`)]);
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Revert visual on error
|
// Revert visual on error
|
||||||
@@ -292,9 +227,6 @@ class TimerToggle extends SingletonAction<TimerSettings> {
|
|||||||
streamDeck.logger.error("Timer toggle failed:", err);
|
streamDeck.logger.error("Timer toggle failed:", err);
|
||||||
await ev.action.showAlert();
|
await ev.action.showAlert();
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
this.pendingKeyDown.delete(ev.action.id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{ "version": "1.0.41" }
|
{ "version": "1.0.38" }
|
||||||
|
|||||||
Reference in New Issue
Block a user