Compare commits
1 Commits
master
...
f0c0639338
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0c0639338 |
@@ -6438,8 +6438,8 @@ async function stopTimer(token, entryId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// src/plugin.ts
|
// src/plugin.ts
|
||||||
var CURRENT_VERSION = "1.0.39";
|
var CURRENT_VERSION = "1.0.24";
|
||||||
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/master";
|
||||||
var SIGNING_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
|
var SIGNING_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
|
||||||
MCowBQYDK2VwAyEAN7ko8TUpuPzPAJuKAZCRjV0c4ZSlou5d9pUAF6o12b4=
|
MCowBQYDK2VwAyEAN7ko8TUpuPzPAJuKAZCRjV0c4ZSlou5d9pUAF6o12b4=
|
||||||
-----END PUBLIC KEY-----`;
|
-----END PUBLIC KEY-----`;
|
||||||
@@ -6456,67 +6456,32 @@ function fetchWithTimeout2(url) {
|
|||||||
const timer = setTimeout(() => controller.abort(), 1e4);
|
const timer = setTimeout(() => controller.abort(), 1e4);
|
||||||
return fetch(url, { signal: controller.signal }).finally(() => clearTimeout(timer));
|
return fetch(url, { signal: controller.signal }).finally(() => clearTimeout(timer));
|
||||||
}
|
}
|
||||||
async function checkForUpdates(sendStatus) {
|
async function checkForUpdates() {
|
||||||
try {
|
try {
|
||||||
const resp = await fetchWithTimeout2(`${GITEA_BASE}/version.json`);
|
const resp = await fetchWithTimeout2(`${GITEA_BASE}/version.json`);
|
||||||
if (!resp.ok) {
|
if (!resp.ok) return;
|
||||||
sendStatus?.("Update check failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const { version } = await resp.json();
|
const { version } = await resp.json();
|
||||||
if (!/^\d+\.\d+\.\d+$/.test(version)) return;
|
if (!/^\d+\.\d+\.\d+$/.test(version)) return;
|
||||||
if (!isNewerVersion(version, CURRENT_VERSION)) {
|
if (!isNewerVersion(version, CURRENT_VERSION)) return;
|
||||||
sendStatus?.(`Already up to date (v${CURRENT_VERSION})`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sendStatus?.(`Updating to v${version}\u2026`);
|
|
||||||
const [pluginResp, sigResp] = await Promise.all([
|
const [pluginResp, sigResp] = await Promise.all([
|
||||||
fetchWithTimeout2(`${GITEA_BASE}/com.pdma.notion-timer.sdPlugin/bin/plugin.js`),
|
fetchWithTimeout2(`${GITEA_BASE}/com.pdma.notion-timer.sdPlugin/bin/plugin.js`),
|
||||||
fetchWithTimeout2(`${GITEA_BASE}/com.pdma.notion-timer.sdPlugin/bin/plugin.js.sig`)
|
fetchWithTimeout2(`${GITEA_BASE}/com.pdma.notion-timer.sdPlugin/bin/plugin.js.sig`)
|
||||||
]);
|
]);
|
||||||
if (!pluginResp.ok || !sigResp.ok) {
|
if (!pluginResp.ok || !sigResp.ok) return;
|
||||||
sendStatus?.("Download failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const newCode = await pluginResp.text();
|
const newCode = await pluginResp.text();
|
||||||
const sigBytes = Buffer.from(await sigResp.arrayBuffer());
|
const sigBytes = Buffer.from(await sigResp.arrayBuffer());
|
||||||
const { verify } = await import("node:crypto");
|
const { verify } = await import("node:crypto");
|
||||||
const valid = verify(null, Buffer.from(newCode), SIGNING_PUBLIC_KEY, sigBytes);
|
const valid = verify(null, Buffer.from(newCode), SIGNING_PUBLIC_KEY, sigBytes);
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
plugin_default.logger.error("Update rejected: signature verification failed");
|
plugin_default.logger.error("Update rejected: signature verification failed");
|
||||||
sendStatus?.("Update rejected: invalid signature");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const fs3 = await import("fs");
|
const fs3 = await import("fs");
|
||||||
const path5 = await import("path");
|
|
||||||
const pluginRoot = path5.join(path5.dirname(__filename), "..");
|
|
||||||
const ASSETS = [
|
|
||||||
"ui/property-inspector.html",
|
|
||||||
"ui/global-property-inspector.html",
|
|
||||||
"imgs/idle.png",
|
|
||||||
"imgs/running.png"
|
|
||||||
];
|
|
||||||
const PLUGIN_BASE = `${GITEA_BASE}/com.pdma.notion-timer.sdPlugin`;
|
|
||||||
const assetResps = await Promise.all(ASSETS.map((p) => fetchWithTimeout2(`${PLUGIN_BASE}/${p}`)));
|
|
||||||
for (let i = 0; i < ASSETS.length; i++) {
|
|
||||||
if (assetResps[i].ok) {
|
|
||||||
fs3.writeFileSync(path5.join(pluginRoot, ASSETS[i]), Buffer.from(await assetResps[i].arrayBuffer()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const LEGACY = ["imgs/idle.svg", "imgs/running.svg"];
|
|
||||||
for (const f of LEGACY) {
|
|
||||||
try {
|
|
||||||
fs3.unlinkSync(path5.join(pluginRoot, f));
|
|
||||||
} catch {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fs3.writeFileSync(__filename, newCode);
|
fs3.writeFileSync(__filename, newCode);
|
||||||
plugin_default.logger.info(`Updated to ${version}, restarting\u2026`);
|
plugin_default.logger.info(`Updated to ${version}, restarting\u2026`);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const msg = err instanceof Error ? err.message : String(err);
|
plugin_default.logger.error(`Update check failed: ${err instanceof Error ? err.message : String(err)}`);
|
||||||
plugin_default.logger.error(`Update check failed: ${msg}`);
|
|
||||||
sendStatus?.(`Error: ${msg}`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var HARDCODED = {
|
var HARDCODED = {
|
||||||
@@ -6527,30 +6492,34 @@ async function getGlobal() {
|
|||||||
const stored = await plugin_default.settings.getGlobalSettings();
|
const stored = await plugin_default.settings.getGlobalSettings();
|
||||||
return { ...stored, ...HARDCODED };
|
return { ...stored, ...HARDCODED };
|
||||||
}
|
}
|
||||||
var memRunningEntryId = void 0;
|
function isConfigured(g) {
|
||||||
var memRunningActionId = void 0;
|
return !!(g.notionToken && g.userId);
|
||||||
async function loadRunningState() {
|
|
||||||
if (memRunningEntryId !== void 0) return;
|
|
||||||
const stored = await plugin_default.settings.getGlobalSettings();
|
|
||||||
memRunningEntryId = stored.runningEntryId ?? null;
|
|
||||||
memRunningActionId = stored.runningActionId ?? null;
|
|
||||||
}
|
}
|
||||||
function setRunningEntry(entryId, actionId) {
|
function buttonTitle(projectName) {
|
||||||
memRunningEntryId = entryId;
|
return projectName.replace(/^[\p{Extended_Pictographic}\uFE0F\s]+/u, "").trim();
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
async function sendProjectsToPI(tokenOverride) {
|
var TimerToggle = class extends SingletonAction {
|
||||||
|
settingsCache = /* @__PURE__ */ new Map();
|
||||||
|
async onWillAppear(ev) {
|
||||||
|
this.settingsCache.set(ev.action.id, ev.payload.settings);
|
||||||
|
const { activeEntryId, projectName } = ev.payload.settings;
|
||||||
|
const title = buttonTitle(projectName || "");
|
||||||
|
if (activeEntryId) {
|
||||||
|
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) {
|
||||||
try {
|
try {
|
||||||
const global = await getGlobal();
|
const global = await getGlobal();
|
||||||
const token = tokenOverride ?? global.notionToken;
|
if (!global.notionToken) {
|
||||||
if (!token) {
|
|
||||||
await plugin_default.ui.sendToPropertyInspector({ event: "projects", data: [], error: "Enter your Notion API token above.", version: CURRENT_VERSION });
|
await plugin_default.ui.sendToPropertyInspector({ event: "projects", data: [], error: "Enter your Notion API token above.", version: CURRENT_VERSION });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const [projects, usersResult] = await Promise.all([
|
const [projects, usersResult] = await Promise.all([
|
||||||
fetchProjects(token, global.projectsDbId),
|
fetchProjects(global.notionToken, global.projectsDbId),
|
||||||
fetchUsers(token).catch((err) => {
|
fetchUsers(global.notionToken).catch((err) => {
|
||||||
plugin_default.logger.error("Failed to fetch users:", err);
|
plugin_default.logger.error("Failed to fetch users:", err);
|
||||||
return [];
|
return [];
|
||||||
})
|
})
|
||||||
@@ -6561,47 +6530,11 @@ async function sendProjectsToPI(tokenOverride) {
|
|||||||
await plugin_default.ui.sendToPropertyInspector({ event: "projects", data: [], error: String(err), version: CURRENT_VERSION });
|
await plugin_default.ui.sendToPropertyInspector({ event: "projects", data: [], error: String(err), version: CURRENT_VERSION });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function isConfigured(g) {
|
|
||||||
return !!(g.notionToken && g.userId);
|
|
||||||
}
|
|
||||||
function buttonTitle(projectName) {
|
|
||||||
return projectName.replace(/^[\p{Extended_Pictographic}\uFE0F\s]+/u, "").trim();
|
|
||||||
}
|
|
||||||
var TimerToggle = class extends SingletonAction {
|
|
||||||
projectCache = /* @__PURE__ */ new Map();
|
|
||||||
async onWillAppear(ev) {
|
|
||||||
this.projectCache.set(ev.action.id, ev.payload.settings);
|
|
||||||
const title = buttonTitle(ev.payload.settings.projectName || "");
|
|
||||||
await loadRunningState();
|
|
||||||
const isRunning = memRunningActionId === ev.action.id;
|
|
||||||
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) {
|
|
||||||
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 +6544,42 @@ 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 ev.action.showOk();
|
||||||
} else {
|
} else {
|
||||||
if (memRunningEntryId) {
|
for (const other of this.actions) {
|
||||||
await stopTimer(global.notionToken, memRunningEntryId);
|
if (other.id === ev.action.id) continue;
|
||||||
|
const otherSettings = this.settingsCache.get(other.id);
|
||||||
|
if (otherSettings?.activeEntryId) {
|
||||||
|
await stopTimer(global.notionToken, otherSettings.activeEntryId);
|
||||||
|
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 || ""));
|
||||||
}
|
}
|
||||||
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(`\u23F1 ${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 ev.action.setState(1);
|
||||||
|
await ev.action.setTitle(`\u23F1 ${title}`);
|
||||||
|
await ev.action.showOk();
|
||||||
}
|
}
|
||||||
} 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();
|
||||||
}
|
}
|
||||||
@@ -6644,14 +6596,6 @@ plugin_default.ui.onSendToPlugin(async (ev) => {
|
|||||||
const title = buttonTitle(ev.payload.settings.projectName || "");
|
const title = buttonTitle(ev.payload.settings.projectName || "");
|
||||||
if (title) await ev.action.setTitle(title);
|
if (title) await ev.action.setTitle(title);
|
||||||
}
|
}
|
||||||
if (ev.payload.event === "refreshProjects") {
|
|
||||||
await sendProjectsToPI(ev.payload.token);
|
|
||||||
}
|
|
||||||
if (ev.payload.event === "checkForUpdates") {
|
|
||||||
const send = (msg) => plugin_default.ui.sendToPropertyInspector({ event: "updateStatus", message: msg });
|
|
||||||
send("Checking\u2026");
|
|
||||||
await checkForUpdates(send);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
plugin_default.connect();
|
plugin_default.connect();
|
||||||
setTimeout(() => checkForUpdates(), 1e4);
|
setTimeout(() => checkForUpdates(), 1e4);
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
в<╥!Ъ░xR√з└СRё;=▀LI"я╓╢HuэF├ы▐Ос─╒┘ sb▌Y╛{йH│╤Н.JщNЦь1╔l
|
ÞòÝRlgˆ¶ª={¸óÞÛd¼H•øXº¿žìÑ æJó0OTù1Š“Änï8àª?—שáƒà}‹IQÉjÊ[
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 21 KiB |
7
com.pdma.notion-timer.sdPlugin/imgs/idle.svg
Normal file
7
com.pdma.notion-timer.sdPlugin/imgs/idle.svg
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 144 144" width="144" height="144">
|
||||||
|
<circle cx="72" cy="58" r="42" fill="none" stroke="#888888" stroke-width="6"/>
|
||||||
|
<line x1="72" y1="58" x2="72" y2="28" stroke="#888888" stroke-width="6" stroke-linecap="round"/>
|
||||||
|
<line x1="72" y1="58" x2="94" y2="71" stroke="#888888" stroke-width="6" stroke-linecap="round"/>
|
||||||
|
<line x1="62" y1="12" x2="82" y2="12" stroke="#888888" stroke-width="6" stroke-linecap="round"/>
|
||||||
|
<line x1="72" y1="12" x2="72" y2="20" stroke="#888888" stroke-width="6" stroke-linecap="round"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 572 B |
Binary file not shown.
|
Before Width: | Height: | Size: 16 KiB |
8
com.pdma.notion-timer.sdPlugin/imgs/running.svg
Normal file
8
com.pdma.notion-timer.sdPlugin/imgs/running.svg
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 144 144" width="144" height="144">
|
||||||
|
<circle cx="72" cy="58" r="42" fill="#1a3a1a" stroke="#4caf50" stroke-width="6"/>
|
||||||
|
<line x1="72" y1="58" x2="72" y2="28" stroke="#4caf50" stroke-width="6" stroke-linecap="round"/>
|
||||||
|
<line x1="72" y1="58" x2="94" y2="71" stroke="#4caf50" stroke-width="6" stroke-linecap="round"/>
|
||||||
|
<line x1="62" y1="12" x2="82" y2="12" stroke="#4caf50" stroke-width="6" stroke-linecap="round"/>
|
||||||
|
<line x1="72" y1="12" x2="72" y2="20" stroke="#4caf50" stroke-width="6" stroke-linecap="round"/>
|
||||||
|
<circle cx="72" cy="58" r="5" fill="#4caf50"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 624 B |
@@ -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.0",
|
||||||
"SDKVersion": 2,
|
"SDKVersion": 2,
|
||||||
"Software": { "MinimumVersion": "5.0" },
|
"Software": { "MinimumVersion": "5.0" },
|
||||||
"OS": [{ "Platform": "mac", "MinimumVersion": "10.11" }],
|
"OS": [{ "Platform": "mac", "MinimumVersion": "10.11" }],
|
||||||
|
|||||||
@@ -88,26 +88,6 @@
|
|||||||
}
|
}
|
||||||
#credStatus.ok { color: #4caf50; }
|
#credStatus.ok { color: #4caf50; }
|
||||||
#credStatus.error { color: #e57373; }
|
#credStatus.error { color: #e57373; }
|
||||||
#updateBtn {
|
|
||||||
display: block;
|
|
||||||
width: 100%;
|
|
||||||
margin-top: 10px;
|
|
||||||
padding: 6px;
|
|
||||||
background: #2a2a2a;
|
|
||||||
border: 1px solid #444;
|
|
||||||
border-radius: 4px;
|
|
||||||
color: #ccc;
|
|
||||||
font-size: 12px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
#updateBtn:hover { background: #333; }
|
|
||||||
#updateStatus {
|
|
||||||
font-size: 11px;
|
|
||||||
color: #888;
|
|
||||||
text-align: center;
|
|
||||||
margin-top: 4px;
|
|
||||||
min-height: 14px;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -145,8 +125,6 @@
|
|||||||
|
|
||||||
<p id="statusText"></p>
|
<p id="statusText"></p>
|
||||||
<p id="versionText"></p>
|
<p id="versionText"></p>
|
||||||
<button id="updateBtn">Check for Updates</button>
|
|
||||||
<p id="updateStatus"></p>
|
|
||||||
|
|
||||||
<script src="libs/constants.js"></script>
|
<script src="libs/constants.js"></script>
|
||||||
<script src="libs/prototypes.js"></script>
|
<script src="libs/prototypes.js"></script>
|
||||||
@@ -161,8 +139,6 @@
|
|||||||
var currentSettings = {};
|
var currentSettings = {};
|
||||||
var credSaveTimer = null;
|
var credSaveTimer = null;
|
||||||
var credConfigured = false;
|
var credConfigured = false;
|
||||||
var globalUserId = "";
|
|
||||||
var cachedUsers = [];
|
|
||||||
|
|
||||||
function setStatus(msg, cls) {
|
function setStatus(msg, cls) {
|
||||||
var el = document.getElementById("statusText");
|
var el = document.getElementById("statusText");
|
||||||
@@ -195,35 +171,27 @@
|
|||||||
userId: document.getElementById("userId").value,
|
userId: document.getElementById("userId").value,
|
||||||
};
|
};
|
||||||
$PI.setGlobalSettings(creds);
|
$PI.setGlobalSettings(creds);
|
||||||
globalUserId = creds.userId;
|
|
||||||
setCredStatus("Credentials saved.", "ok");
|
setCredStatus("Credentials saved.", "ok");
|
||||||
}
|
}
|
||||||
|
|
||||||
function scheduleCredSave() {
|
function populateUsers(users, savedUserId) {
|
||||||
clearTimeout(credSaveTimer);
|
|
||||||
credSaveTimer = setTimeout(function() {
|
|
||||||
saveCredentials();
|
|
||||||
var token = document.getElementById("notionToken").value.trim();
|
|
||||||
if (token) {
|
|
||||||
setStatus("Loading…", "");
|
|
||||||
$PI.sendToPlugin({ event: "refreshProjects", token: token });
|
|
||||||
}
|
|
||||||
}, 600);
|
|
||||||
}
|
|
||||||
|
|
||||||
function populateUsers(users, userId) {
|
|
||||||
cachedUsers = users;
|
|
||||||
var sel = document.getElementById("userId");
|
var sel = document.getElementById("userId");
|
||||||
|
var current = savedUserId || sel.value;
|
||||||
sel.innerHTML = '<option value="">— Select your name —</option>';
|
sel.innerHTML = '<option value="">— Select your name —</option>';
|
||||||
users.forEach(function(u) {
|
users.forEach(function(u) {
|
||||||
var opt = document.createElement("option");
|
var opt = document.createElement("option");
|
||||||
opt.value = u.id;
|
opt.value = u.id;
|
||||||
opt.textContent = u.name;
|
opt.textContent = u.name;
|
||||||
if (u.id === userId) opt.selected = true;
|
if (u.id === current) opt.selected = true;
|
||||||
sel.appendChild(opt);
|
sel.appendChild(opt);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function scheduleCredSave() {
|
||||||
|
clearTimeout(credSaveTimer);
|
||||||
|
credSaveTimer = setTimeout(saveCredentials, 600);
|
||||||
|
}
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
var sel = document.getElementById("projectSelect");
|
var sel = document.getElementById("projectSelect");
|
||||||
var opt = sel.options[sel.selectedIndex];
|
var opt = sel.options[sel.selectedIndex];
|
||||||
@@ -261,19 +229,16 @@
|
|||||||
document.getElementById("projectSelect").addEventListener("change", save);
|
document.getElementById("projectSelect").addEventListener("change", save);
|
||||||
document.getElementById("notionToken").addEventListener("input", scheduleCredSave);
|
document.getElementById("notionToken").addEventListener("input", scheduleCredSave);
|
||||||
document.getElementById("userId").addEventListener("change", saveCredentials);
|
document.getElementById("userId").addEventListener("change", saveCredentials);
|
||||||
document.getElementById("updateBtn").addEventListener("click", function() {
|
|
||||||
document.getElementById("updateStatus").textContent = "";
|
|
||||||
$PI.sendToPlugin({ event: "checkForUpdates" });
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$PI.onDidReceiveGlobalSettings(function(jsn) {
|
$PI.onDidReceiveGlobalSettings(function(jsn) {
|
||||||
var s = jsn.payload.settings || {};
|
var s = jsn.payload.settings || {};
|
||||||
document.getElementById("notionToken").value = s.notionToken || "";
|
document.getElementById("notionToken").value = s.notionToken || "";
|
||||||
globalUserId = s.userId || "";
|
if (s.userId) {
|
||||||
if (globalUserId && cachedUsers.length > 0) {
|
var sel = document.getElementById("userId");
|
||||||
// Users already loaded — re-populate with correct selection
|
if (sel.querySelector('option[value="' + s.userId + '"]')) {
|
||||||
populateUsers(cachedUsers, globalUserId);
|
sel.value = s.userId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
credConfigured = !!(s.notionToken && s.userId);
|
credConfigured = !!(s.notionToken && s.userId);
|
||||||
@@ -303,15 +268,13 @@
|
|||||||
|
|
||||||
$PI.onSendToPropertyInspector(ACTION_UUID, function(jsn) {
|
$PI.onSendToPropertyInspector(ACTION_UUID, function(jsn) {
|
||||||
var payload = jsn.payload;
|
var payload = jsn.payload;
|
||||||
if (payload.event === "updateStatus") {
|
|
||||||
document.getElementById("updateStatus").textContent = payload.message;
|
|
||||||
}
|
|
||||||
if (payload.event === "projects") {
|
if (payload.event === "projects") {
|
||||||
if (payload.version) {
|
if (payload.version) {
|
||||||
document.getElementById("versionText").textContent = "v" + payload.version;
|
document.getElementById("versionText").textContent = "v" + payload.version;
|
||||||
}
|
}
|
||||||
if (payload.users) {
|
if (payload.users) {
|
||||||
populateUsers(payload.users, globalUserId);
|
var savedUserId = document.getElementById("userId").value;
|
||||||
|
populateUsers(payload.users, savedUserId);
|
||||||
}
|
}
|
||||||
if (payload.error) {
|
if (payload.error) {
|
||||||
setStatus(payload.error, "error");
|
setStatus(payload.error, "error");
|
||||||
|
|||||||
Binary file not shown.
214
src/plugin.ts
214
src/plugin.ts
@@ -1,5 +1,5 @@
|
|||||||
const CURRENT_VERSION = "1.0.39";
|
const CURRENT_VERSION = "1.0.24";
|
||||||
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/master";
|
||||||
const SIGNING_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
|
const SIGNING_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
|
||||||
MCowBQYDK2VwAyEAN7ko8TUpuPzPAJuKAZCRjV0c4ZSlou5d9pUAF6o12b4=
|
MCowBQYDK2VwAyEAN7ko8TUpuPzPAJuKAZCRjV0c4ZSlou5d9pUAF6o12b4=
|
||||||
-----END PUBLIC KEY-----`;
|
-----END PUBLIC KEY-----`;
|
||||||
@@ -19,23 +19,19 @@ function fetchWithTimeout(url: string): Promise<Response> {
|
|||||||
return fetch(url, { signal: controller.signal }).finally(() => clearTimeout(timer));
|
return fetch(url, { signal: controller.signal }).finally(() => clearTimeout(timer));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function checkForUpdates(sendStatus?: (msg: string) => void): Promise<void> {
|
async function checkForUpdates(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const resp = await fetchWithTimeout(`${GITEA_BASE}/version.json`);
|
const resp = await fetchWithTimeout(`${GITEA_BASE}/version.json`);
|
||||||
if (!resp.ok) { sendStatus?.("Update check failed"); return; }
|
if (!resp.ok) return;
|
||||||
const { version } = await resp.json() as { version: string };
|
const { version } = await resp.json() as { version: string };
|
||||||
if (!/^\d+\.\d+\.\d+$/.test(version)) return;
|
if (!/^\d+\.\d+\.\d+$/.test(version)) return;
|
||||||
if (!isNewerVersion(version, CURRENT_VERSION)) {
|
if (!isNewerVersion(version, CURRENT_VERSION)) return;
|
||||||
sendStatus?.(`Already up to date (v${CURRENT_VERSION})`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
sendStatus?.(`Updating to v${version}…`);
|
|
||||||
const [pluginResp, sigResp] = await Promise.all([
|
const [pluginResp, sigResp] = await Promise.all([
|
||||||
fetchWithTimeout(`${GITEA_BASE}/com.pdma.notion-timer.sdPlugin/bin/plugin.js`),
|
fetchWithTimeout(`${GITEA_BASE}/com.pdma.notion-timer.sdPlugin/bin/plugin.js`),
|
||||||
fetchWithTimeout(`${GITEA_BASE}/com.pdma.notion-timer.sdPlugin/bin/plugin.js.sig`),
|
fetchWithTimeout(`${GITEA_BASE}/com.pdma.notion-timer.sdPlugin/bin/plugin.js.sig`),
|
||||||
]);
|
]);
|
||||||
if (!pluginResp.ok || !sigResp.ok) { sendStatus?.("Download failed"); return; }
|
if (!pluginResp.ok || !sigResp.ok) return;
|
||||||
|
|
||||||
const newCode = await pluginResp.text();
|
const newCode = await pluginResp.text();
|
||||||
const sigBytes = Buffer.from(await sigResp.arrayBuffer());
|
const sigBytes = Buffer.from(await sigResp.arrayBuffer());
|
||||||
@@ -44,40 +40,15 @@ async function checkForUpdates(sendStatus?: (msg: string) => void): Promise<void
|
|||||||
const valid = verify(null, Buffer.from(newCode), SIGNING_PUBLIC_KEY, sigBytes);
|
const valid = verify(null, Buffer.from(newCode), SIGNING_PUBLIC_KEY, sigBytes);
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
streamDeck.logger.error("Update rejected: signature verification failed");
|
streamDeck.logger.error("Update rejected: signature verification failed");
|
||||||
sendStatus?.("Update rejected: invalid signature");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fs = await import("fs");
|
const fs = await import("fs");
|
||||||
const path = await import("path");
|
|
||||||
const pluginRoot = path.join(path.dirname(__filename), "..");
|
|
||||||
|
|
||||||
const ASSETS = [
|
|
||||||
"ui/property-inspector.html",
|
|
||||||
"ui/global-property-inspector.html",
|
|
||||||
"imgs/idle.png",
|
|
||||||
"imgs/running.png",
|
|
||||||
];
|
|
||||||
const PLUGIN_BASE = `${GITEA_BASE}/com.pdma.notion-timer.sdPlugin`;
|
|
||||||
const assetResps = await Promise.all(ASSETS.map(p => fetchWithTimeout(`${PLUGIN_BASE}/${p}`)));
|
|
||||||
for (let i = 0; i < ASSETS.length; i++) {
|
|
||||||
if (assetResps[i].ok) {
|
|
||||||
fs.writeFileSync(path.join(pluginRoot, ASSETS[i]), Buffer.from(await assetResps[i].arrayBuffer()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const LEGACY = ["imgs/idle.svg", "imgs/running.svg"];
|
|
||||||
for (const f of LEGACY) {
|
|
||||||
try { fs.unlinkSync(path.join(pluginRoot, f)); } catch { /* already gone */ }
|
|
||||||
}
|
|
||||||
|
|
||||||
fs.writeFileSync(__filename, newCode);
|
fs.writeFileSync(__filename, newCode);
|
||||||
streamDeck.logger.info(`Updated to ${version}, restarting…`);
|
streamDeck.logger.info(`Updated to ${version}, restarting…`);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const msg = err instanceof Error ? err.message : String(err);
|
streamDeck.logger.error(`Update check failed: ${err instanceof Error ? err.message : String(err)}`);
|
||||||
streamDeck.logger.error(`Update check failed: ${msg}`);
|
|
||||||
sendStatus?.(`Error: ${msg}`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,13 +66,12 @@ interface GlobalSettings {
|
|||||||
timingDbId: string;
|
timingDbId: string;
|
||||||
projectsDbId: string;
|
projectsDbId: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
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,37 +84,40 @@ async function getGlobal(): Promise<GlobalSettings> {
|
|||||||
return { ...stored, ...HARDCODED };
|
return { ...stored, ...HARDCODED };
|
||||||
}
|
}
|
||||||
|
|
||||||
// In-memory running state — avoids async round-trips on every button press
|
function isConfigured(g: GlobalSettings): boolean {
|
||||||
let memRunningEntryId: string | null | undefined = undefined;
|
return !!(g.notionToken && g.userId);
|
||||||
let memRunningActionId: string | null | undefined = undefined;
|
|
||||||
|
|
||||||
async function loadRunningState(): Promise<void> {
|
|
||||||
if (memRunningEntryId !== undefined) return;
|
|
||||||
const stored = await streamDeck.settings.getGlobalSettings<GlobalSettings>();
|
|
||||||
memRunningEntryId = stored.runningEntryId ?? null;
|
|
||||||
memRunningActionId = stored.runningActionId ?? null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setRunningEntry(entryId: string | null, actionId: string | null): void {
|
// Strip leading emoji characters so the button title shows just the project name
|
||||||
memRunningEntryId = entryId;
|
function buttonTitle(projectName: string): string {
|
||||||
memRunningActionId = actionId;
|
return projectName.replace(/^[\p{Extended_Pictographic}\uFE0F\s]+/u, "").trim();
|
||||||
// Persist in background — do not await, so the visual is never blocked
|
|
||||||
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> {
|
@action({ UUID: "com.pdma.notion-timer.toggle" })
|
||||||
|
class TimerToggle extends SingletonAction<TimerSettings> {
|
||||||
|
private settingsCache = new Map<string, TimerSettings>();
|
||||||
|
|
||||||
|
async onWillAppear(ev: WillAppearEvent<TimerSettings>): Promise<void> {
|
||||||
|
this.settingsCache.set(ev.action.id, ev.payload.settings);
|
||||||
|
const { activeEntryId, projectName } = ev.payload.settings;
|
||||||
|
const title = buttonTitle(projectName || "");
|
||||||
|
if (activeEntryId) {
|
||||||
|
await Promise.all([ev.action.setState(1), ev.action.setTitle(`⏱ ${title}`)]);
|
||||||
|
} else {
|
||||||
|
await Promise.all([ev.action.setState(0), ev.action.setTitle(title)]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async onPropertyInspectorDidAppear(ev: PropertyInspectorDidAppearEvent<TimerSettings>): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const global = await getGlobal();
|
const global = await getGlobal();
|
||||||
const token = tokenOverride ?? global.notionToken;
|
if (!global.notionToken) {
|
||||||
if (!token) {
|
|
||||||
await streamDeck.ui.sendToPropertyInspector({ event: "projects", data: [], error: "Enter your Notion API token above.", version: CURRENT_VERSION });
|
await streamDeck.ui.sendToPropertyInspector({ event: "projects", data: [], error: "Enter your Notion API token above.", version: CURRENT_VERSION });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const [projects, usersResult] = await Promise.all([
|
const [projects, usersResult] = await Promise.all([
|
||||||
fetchProjects(token, global.projectsDbId),
|
fetchProjects(global.notionToken, global.projectsDbId),
|
||||||
fetchUsers(token).catch((err) => {
|
fetchUsers(global.notionToken).catch((err) => {
|
||||||
streamDeck.logger.error("Failed to fetch users:", err);
|
streamDeck.logger.error("Failed to fetch users:", err);
|
||||||
return [];
|
return [];
|
||||||
}),
|
}),
|
||||||
@@ -156,78 +129,61 @@ async function sendProjectsToPI(tokenOverride?: string): Promise<void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isConfigured(g: GlobalSettings): boolean {
|
|
||||||
return !!(g.notionToken && g.userId);
|
|
||||||
}
|
|
||||||
|
|
||||||
function buttonTitle(projectName: string): string {
|
|
||||||
return projectName.replace(/^[\p{Extended_Pictographic}\uFE0F\s]+/u, "").trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
@action({ UUID: "com.pdma.notion-timer.toggle" })
|
|
||||||
class TimerToggle extends SingletonAction<TimerSettings> {
|
|
||||||
private projectCache = new Map<string, TimerSettings>();
|
|
||||||
|
|
||||||
async onWillAppear(ev: WillAppearEvent<TimerSettings>): Promise<void> {
|
|
||||||
this.projectCache.set(ev.action.id, ev.payload.settings);
|
|
||||||
const title = buttonTitle(ev.payload.settings.projectName || "");
|
|
||||||
await loadRunningState();
|
|
||||||
const isRunning = memRunningActionId === ev.action.id;
|
|
||||||
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)]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async onPropertyInspectorDidAppear(_ev: PropertyInspectorDidAppearEvent<TimerSettings>): Promise<void> {
|
|
||||||
await sendProjectsToPI();
|
|
||||||
}
|
|
||||||
|
|
||||||
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 title = buttonTitle(projectName || "");
|
|
||||||
const isRunning = memRunningActionId === ev.action.id;
|
|
||||||
|
|
||||||
// Instant visual feedback — no setSettings, no flash
|
|
||||||
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(`⏱ ${title}`)]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const global = await getGlobal();
|
const global = await getGlobal();
|
||||||
if (!isConfigured(global)) { await ev.action.showAlert(); return; }
|
const { projectId, projectName, activeEntryId } = ev.payload.settings;
|
||||||
if (!projectId) { await ev.action.showAlert(); return; }
|
const title = buttonTitle(projectName || "");
|
||||||
|
|
||||||
|
if (!isConfigured(global)) {
|
||||||
|
await ev.action.showAlert();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!projectId) {
|
||||||
|
await ev.action.showAlert();
|
||||||
|
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 ev.action.showOk();
|
||||||
} else {
|
} else {
|
||||||
if (memRunningEntryId) {
|
// Stop any other running timer first
|
||||||
await stopTimer(global.notionToken, memRunningEntryId);
|
for (const other of this.actions) {
|
||||||
|
if (other.id === ev.action.id) continue;
|
||||||
|
const otherSettings = this.settingsCache.get(other.id);
|
||||||
|
if (otherSettings?.activeEntryId) {
|
||||||
|
await stopTimer(global.notionToken, otherSettings.activeEntryId);
|
||||||
|
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 || ""));
|
||||||
}
|
}
|
||||||
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(`⏱ ${title}`)]);
|
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 ev.action.setState(1);
|
||||||
|
await ev.action.setTitle(`⏱ ${title}`);
|
||||||
|
await ev.action.showOk();
|
||||||
}
|
}
|
||||||
} 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,22 +193,16 @@ class TimerToggle extends SingletonAction<TimerSettings> {
|
|||||||
const timerAction = new TimerToggle();
|
const timerAction = new TimerToggle();
|
||||||
streamDeck.actions.registerAction(timerAction);
|
streamDeck.actions.registerAction(timerAction);
|
||||||
|
|
||||||
streamDeck.ui.onSendToPlugin<{ event: string; settings?: TimerSettings; token?: string }>(async (ev) => {
|
// v2 requires using streamDeck.ui.onSendToPlugin — the SingletonAction method does not fire
|
||||||
|
streamDeck.ui.onSendToPlugin<{ event: string; settings?: TimerSettings }>(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);
|
||||||
const title = buttonTitle(ev.payload.settings.projectName || "");
|
const title = buttonTitle(ev.payload.settings.projectName || "");
|
||||||
if (title) await ev.action.setTitle(title);
|
if (title) await ev.action.setTitle(title);
|
||||||
}
|
}
|
||||||
if (ev.payload.event === "refreshProjects") {
|
|
||||||
await sendProjectsToPI(ev.payload.token);
|
|
||||||
}
|
|
||||||
if (ev.payload.event === "checkForUpdates") {
|
|
||||||
const send = (msg: string) => streamDeck.ui.sendToPropertyInspector({ event: "updateStatus", message: msg });
|
|
||||||
send("Checking…");
|
|
||||||
await checkForUpdates(send);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
streamDeck.connect();
|
streamDeck.connect();
|
||||||
|
|
||||||
|
// Check for updates 10 seconds after startup to avoid disrupting initial connection
|
||||||
setTimeout(() => checkForUpdates(), 10_000);
|
setTimeout(() => checkForUpdates(), 10_000);
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{ "version": "1.0.39" }
|
{ "version": "1.0.14" }
|
||||||
|
|||||||
Reference in New Issue
Block a user