Compare commits
3 Commits
1294688b40
...
stable-reb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f76c5ac33b | ||
|
|
6e0976a284 | ||
|
|
060a2bc917 |
@@ -6438,7 +6438,7 @@ async function stopTimer(token, entryId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// src/plugin.ts
|
// src/plugin.ts
|
||||||
var CURRENT_VERSION = "1.0.38";
|
var CURRENT_VERSION = "1.0.40";
|
||||||
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,11 +6535,10 @@ async function loadRunningState() {
|
|||||||
memRunningEntryId = stored.runningEntryId ?? null;
|
memRunningEntryId = stored.runningEntryId ?? null;
|
||||||
memRunningActionId = stored.runningActionId ?? null;
|
memRunningActionId = stored.runningActionId ?? null;
|
||||||
}
|
}
|
||||||
async function setRunningEntry(entryId, actionId) {
|
function setRunningEntry(entryId, actionId) {
|
||||||
memRunningEntryId = entryId;
|
memRunningEntryId = entryId;
|
||||||
memRunningActionId = actionId;
|
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, runningActionId: actionId });
|
|
||||||
}
|
}
|
||||||
async function sendProjectsToPI(tokenOverride) {
|
async function sendProjectsToPI(tokenOverride) {
|
||||||
try {
|
try {
|
||||||
@@ -6570,6 +6569,7 @@ function buttonTitle(projectName) {
|
|||||||
}
|
}
|
||||||
var TimerToggle = class extends SingletonAction {
|
var TimerToggle = class extends SingletonAction {
|
||||||
projectCache = /* @__PURE__ */ new Map();
|
projectCache = /* @__PURE__ */ new Map();
|
||||||
|
pendingKeyDown = /* @__PURE__ */ new Set();
|
||||||
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 || "");
|
||||||
@@ -6585,50 +6585,58 @@ var TimerToggle = class extends SingletonAction {
|
|||||||
await sendProjectsToPI();
|
await sendProjectsToPI();
|
||||||
}
|
}
|
||||||
async onKeyDown(ev) {
|
async onKeyDown(ev) {
|
||||||
const { projectId, projectName } = ev.payload.settings;
|
if (this.pendingKeyDown.has(ev.action.id)) return;
|
||||||
const title = buttonTitle(projectName || "");
|
this.pendingKeyDown.add(ev.action.id);
|
||||||
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();
|
|
||||||
if (!isConfigured(global)) {
|
|
||||||
await ev.action.showAlert();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!projectId) {
|
|
||||||
await ev.action.showAlert();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
if (isRunning) {
|
const { projectId, projectName } = ev.payload.settings;
|
||||||
await stopTimer(global.notionToken, memRunningEntryId);
|
const title = buttonTitle(projectName || "");
|
||||||
await setRunningEntry(null, null);
|
const isRunning = memRunningActionId === ev.action.id;
|
||||||
} else {
|
if (projectId) {
|
||||||
if (memRunningEntryId) {
|
if (isRunning) {
|
||||||
await stopTimer(global.notionToken, memRunningEntryId);
|
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 entryId = await startTimer(global.notionToken, global.timingDbId, projectId, projectName, global.userId);
|
|
||||||
await setRunningEntry(entryId, ev.action.id);
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
const global = await getGlobal();
|
||||||
await Promise.all([
|
if (!isConfigured(global)) {
|
||||||
ev.action.setState(isRunning ? 1 : 0),
|
await ev.action.showAlert();
|
||||||
ev.action.setTitle(isRunning ? `\u23F1 ${title}` : title)
|
return;
|
||||||
]);
|
}
|
||||||
plugin_default.logger.error("Timer toggle failed:", err);
|
if (!projectId) {
|
||||||
await ev.action.showAlert();
|
await ev.action.showAlert();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (isRunning) {
|
||||||
|
await stopTimer(global.notionToken, memRunningEntryId);
|
||||||
|
setRunningEntry(null, null);
|
||||||
|
await Promise.all([ev.action.setState(0), ev.action.setTitle(title)]);
|
||||||
|
} else {
|
||||||
|
if (memRunningEntryId) {
|
||||||
|
await stopTimer(global.notionToken, memRunningEntryId);
|
||||||
|
}
|
||||||
|
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}`)]);
|
||||||
|
}
|
||||||
|
} 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);
|
||||||
|
await ev.action.showAlert();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
this.pendingKeyDown.delete(ev.action.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
Κ¤<06>C¤•Sί¤
|
{QÕ¿óîj¶?Íz_ÎDA+ÌOÎi °<u,&/Õ+ødeÆá¤"÷œSw+&öO.RC‘&óä^H-¯
|
||||||
Φ®Έ}•~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.38",
|
"Version": "1.0.39",
|
||||||
"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/master/notion-timer.streamDeckPlugin" -o "${PLUGIN_FILE}"
|
curl -sL "${GITEA}/${REPO}/raw/branch/stable-rebuild/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 && rm -f notion-timer.streamDeckPlugin && zip -r notion-timer.streamDeckPlugin com.pdma.notion-timer.sdPlugin && echo 'Packaged: notion-timer.streamDeckPlugin'",
|
"package": "npm run build && 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.38";
|
const CURRENT_VERSION = "1.0.40";
|
||||||
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,11 +125,13 @@ async function loadRunningState(): Promise<void> {
|
|||||||
memRunningActionId = stored.runningActionId ?? null;
|
memRunningActionId = stored.runningActionId ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setRunningEntry(entryId: string | null, actionId: string | null): Promise<void> {
|
function setRunningEntry(entryId: string | null, actionId: string | null): void {
|
||||||
memRunningEntryId = entryId;
|
memRunningEntryId = entryId;
|
||||||
memRunningActionId = actionId;
|
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, runningActionId: actionId });
|
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> {
|
||||||
@@ -165,6 +167,7 @@ function buttonTitle(projectName: string): string {
|
|||||||
@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>();
|
||||||
|
|
||||||
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);
|
||||||
@@ -183,6 +186,9 @@ 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;
|
||||||
@@ -210,13 +216,15 @@ class TimerToggle extends SingletonAction<TimerSettings> {
|
|||||||
try {
|
try {
|
||||||
if (isRunning) {
|
if (isRunning) {
|
||||||
await stopTimer(global.notionToken, memRunningEntryId!);
|
await stopTimer(global.notionToken, memRunningEntryId!);
|
||||||
await setRunningEntry(null, null);
|
setRunningEntry(null, null);
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
const entryId = await startTimer(global.notionToken, global.timingDbId, projectId, projectName, global.userId);
|
const entryId = await startTimer(global.notionToken, global.timingDbId, projectId, projectName, global.userId);
|
||||||
await setRunningEntry(entryId, ev.action.id);
|
setRunningEntry(entryId, ev.action.id);
|
||||||
|
await Promise.all([ev.action.setState(1), ev.action.setTitle(`⏱ ${title}`)]);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Revert visual on error
|
// Revert visual on error
|
||||||
@@ -227,6 +235,9 @@ 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.38" }
|
{ "version": "1.0.40" }
|
||||||
|
|||||||
Reference in New Issue
Block a user