Compare commits
18 Commits
52216495c2
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
060a2bc917 | ||
|
|
4171b2f6e9 | ||
|
|
35a0bbb867 | ||
|
|
5cdc77ccf3 | ||
|
|
bb021633a3 | ||
|
|
93616d3a1a | ||
|
|
2fd2b6ad8a | ||
|
|
e3a19234a9 | ||
|
|
a233cfc4fd | ||
|
|
036567bc7c | ||
|
|
ccc6d90578 | ||
|
|
c3add8da27 | ||
|
|
5426a388ba | ||
|
|
034c951d9b | ||
|
|
d6d695e6c0 | ||
|
|
47d8c7d98d | ||
|
|
3a91fafe8f | ||
|
|
d9a91fe5b1 |
@@ -6438,7 +6438,7 @@ async function stopTimer(token, entryId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// src/plugin.ts
|
// src/plugin.ts
|
||||||
var CURRENT_VERSION = "1.0.26";
|
var CURRENT_VERSION = "1.0.39";
|
||||||
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=
|
||||||
@@ -6488,6 +6488,28 @@ async function checkForUpdates(sendStatus) {
|
|||||||
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);
|
||||||
@@ -6506,55 +6528,29 @@ async function getGlobal() {
|
|||||||
return { ...stored, ...HARDCODED };
|
return { ...stored, ...HARDCODED };
|
||||||
}
|
}
|
||||||
var memRunningEntryId = void 0;
|
var memRunningEntryId = void 0;
|
||||||
async function getRunningEntryId() {
|
var memRunningActionId = void 0;
|
||||||
if (memRunningEntryId === void 0) {
|
async function loadRunningState() {
|
||||||
|
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;
|
||||||
const stored = await plugin_default.settings.getGlobalSettings();
|
memRunningActionId = actionId;
|
||||||
await plugin_default.settings.setGlobalSettings({ ...stored, runningEntryId: entryId });
|
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));
|
||||||
}
|
}
|
||||||
function isConfigured(g) {
|
async function sendProjectsToPI(tokenOverride) {
|
||||||
return !!(g.notionToken && g.userId);
|
|
||||||
}
|
|
||||||
function buttonTitle(projectName) {
|
|
||||||
return projectName.replace(/^[\p{Extended_Pictographic}\uFE0F\s]+/u, "").trim();
|
|
||||||
}
|
|
||||||
var TimerToggle = class extends SingletonAction {
|
|
||||||
settingsCache = /* @__PURE__ */ new Map();
|
|
||||||
async onWillAppear(ev) {
|
|
||||||
const { activeEntryId, projectName } = ev.payload.settings;
|
|
||||||
const title = buttonTitle(projectName || "");
|
|
||||||
const running = await getRunningEntryId();
|
|
||||||
const isRunning = !!activeEntryId && activeEntryId === running;
|
|
||||||
if (activeEntryId && !isRunning) {
|
|
||||||
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)]);
|
|
||||||
} 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) {
|
|
||||||
try {
|
try {
|
||||||
const global = await getGlobal();
|
const global = await getGlobal();
|
||||||
if (!global.notionToken) {
|
const token = tokenOverride ?? 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(global.notionToken, global.projectsDbId),
|
fetchProjects(token, global.projectsDbId),
|
||||||
fetchUsers(global.notionToken).catch((err) => {
|
fetchUsers(token).catch((err) => {
|
||||||
plugin_default.logger.error("Failed to fetch users:", err);
|
plugin_default.logger.error("Failed to fetch users:", err);
|
||||||
return [];
|
return [];
|
||||||
})
|
})
|
||||||
@@ -6565,11 +6561,47 @@ var TimerToggle = class extends SingletonAction {
|
|||||||
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) {
|
||||||
this.settingsCache.set(ev.action.id, ev.payload.settings);
|
const { projectId, projectName } = 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;
|
||||||
|
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)) {
|
if (!isConfigured(global)) {
|
||||||
await ev.action.showAlert();
|
await ev.action.showAlert();
|
||||||
return;
|
return;
|
||||||
@@ -6579,51 +6611,23 @@ var TimerToggle = class extends SingletonAction {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (activeEntryId) {
|
if (isRunning) {
|
||||||
await stopTimer(global.notionToken, activeEntryId);
|
await stopTimer(global.notionToken, memRunningEntryId);
|
||||||
const stopped = { ...ev.payload.settings, activeEntryId: null };
|
setRunningEntry(null, null);
|
||||||
await ev.action.setSettings(stopped);
|
await Promise.all([ev.action.setState(0), ev.action.setTitle(title)]);
|
||||||
this.settingsCache.set(ev.action.id, stopped);
|
|
||||||
await ev.action.setState(0);
|
|
||||||
await ev.action.setTitle(title);
|
|
||||||
await setRunningEntry(null);
|
|
||||||
} else {
|
} else {
|
||||||
const prevEntryId = await getRunningEntryId();
|
if (memRunningEntryId) {
|
||||||
if (prevEntryId) {
|
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 === 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();
|
||||||
}
|
}
|
||||||
@@ -6640,6 +6644,9 @@ 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") {
|
if (ev.payload.event === "checkForUpdates") {
|
||||||
const send = (msg) => plugin_default.ui.sendToPropertyInspector({ event: "updateStatus", message: msg });
|
const send = (msg) => plugin_default.ui.sendToPropertyInspector({ event: "updateStatus", message: msg });
|
||||||
send("Checking\u2026");
|
send("Checking\u2026");
|
||||||
|
|||||||
Binary file not shown.
@@ -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.0",
|
"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" }],
|
||||||
|
|||||||
@@ -127,7 +127,6 @@
|
|||||||
<option value="">— Select your name —</option>
|
<option value="">— Select your name —</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<p id="userError" class="hint" style="color:#e57373;padding-left:0;"></p>
|
|
||||||
<p class="hint">Shared across all buttons. Select once per device.</p>
|
<p class="hint">Shared across all buttons. Select once per device.</p>
|
||||||
<p id="credStatus"></p>
|
<p id="credStatus"></p>
|
||||||
<hr class="divider">
|
<hr class="divider">
|
||||||
@@ -162,6 +161,8 @@
|
|||||||
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");
|
||||||
@@ -194,30 +195,35 @@
|
|||||||
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");
|
||||||
if (creds.notionToken) {
|
|
||||||
$PI.sendToPlugin({ event: "refresh", notionToken: creds.notionToken });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function populateUsers(users, savedUserId) {
|
function scheduleCredSave() {
|
||||||
|
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 === current) opt.selected = true;
|
if (u.id === userId) 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];
|
||||||
@@ -264,11 +270,10 @@
|
|||||||
$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 || "";
|
||||||
if (s.userId) {
|
globalUserId = s.userId || "";
|
||||||
var sel = document.getElementById("userId");
|
if (globalUserId && cachedUsers.length > 0) {
|
||||||
if (sel.querySelector('option[value="' + s.userId + '"]')) {
|
// Users already loaded — re-populate with correct selection
|
||||||
sel.value = s.userId;
|
populateUsers(cachedUsers, globalUserId);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
credConfigured = !!(s.notionToken && s.userId);
|
credConfigured = !!(s.notionToken && s.userId);
|
||||||
@@ -300,25 +305,13 @@
|
|||||||
var payload = jsn.payload;
|
var payload = jsn.payload;
|
||||||
if (payload.event === "updateStatus") {
|
if (payload.event === "updateStatus") {
|
||||||
document.getElementById("updateStatus").textContent = payload.message;
|
document.getElementById("updateStatus").textContent = payload.message;
|
||||||
if (payload.message && payload.message.indexOf("Updating") === 0) {
|
|
||||||
setTimeout(function() { location.reload(); }, 4000);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
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 !== undefined) {
|
if (payload.users) {
|
||||||
var savedUserId = document.getElementById("userId").value;
|
populateUsers(payload.users, globalUserId);
|
||||||
populateUsers(payload.users, savedUserId);
|
|
||||||
var userErr = document.getElementById("userError");
|
|
||||||
if (payload.usersError) {
|
|
||||||
userErr.textContent = "Could not load names: " + payload.usersError;
|
|
||||||
} else if (payload.users.length === 0) {
|
|
||||||
userErr.textContent = "No users found — check the integration has \u201cRead user information\u201d enabled.";
|
|
||||||
} else {
|
|
||||||
userErr.textContent = "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (payload.error) {
|
if (payload.error) {
|
||||||
setStatus(payload.error, "error");
|
setStatus(payload.error, "error");
|
||||||
|
|||||||
@@ -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\"",
|
||||||
|
|||||||
183
src/plugin.ts
183
src/plugin.ts
@@ -1,20 +1,16 @@
|
|||||||
const CURRENT_VERSION = "1.0.22";
|
const CURRENT_VERSION = "1.0.39";
|
||||||
const GITEA_BASE = "https://gitea.pdmarf.co.uk/pdm/stream_deck_notion_timer/raw/branch/master";
|
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=
|
||||||
-----END PUBLIC KEY-----`;
|
-----END PUBLIC KEY-----`;
|
||||||
|
|
||||||
function isNewerVersion(remote: string, current: string): boolean {
|
function isNewerVersion(remote: string, current: string): boolean {
|
||||||
const parse = (v: string) => v.split(".").map(Number);
|
const parse = (v: string) => v.split(".").map(Number);
|
||||||
const r = parse(remote);
|
const [rMaj, rMin, rPat] = parse(remote);
|
||||||
const c = parse(current);
|
const [cMaj, cMin, cPat] = parse(current);
|
||||||
const len = Math.max(r.length, c.length);
|
if (rMaj !== cMaj) return rMaj > cMaj;
|
||||||
for (let i = 0; i < len; i++) {
|
if (rMin !== cMin) return rMin > cMin;
|
||||||
const rv = r[i] ?? 0;
|
return rPat > cPat;
|
||||||
const cv = c[i] ?? 0;
|
|
||||||
if (rv !== cv) return rv > cv;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetchWithTimeout(url: string): Promise<Response> {
|
function fetchWithTimeout(url: string): Promise<Response> {
|
||||||
@@ -28,17 +24,16 @@ async function checkForUpdates(sendStatus?: (msg: string) => void): Promise<void
|
|||||||
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) { sendStatus?.("Update check failed"); return; }
|
||||||
const { version } = await resp.json() as { version: string };
|
const { version } = await resp.json() as { version: string };
|
||||||
if (!/^\d+(\.\d+)+$/.test(version)) return;
|
if (!/^\d+\.\d+\.\d+$/.test(version)) return;
|
||||||
if (!isNewerVersion(version, CURRENT_VERSION)) {
|
if (!isNewerVersion(version, CURRENT_VERSION)) {
|
||||||
sendStatus?.(`Already up to date (v${CURRENT_VERSION})`);
|
sendStatus?.(`Already up to date (v${CURRENT_VERSION})`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sendStatus?.(`Updating to v${version}…`);
|
sendStatus?.(`Updating to v${version}…`);
|
||||||
const PLUGIN_BASE = `${GITEA_BASE}/com.pdma.notion-timer.sdPlugin`;
|
|
||||||
const [pluginResp, sigResp] = await Promise.all([
|
const [pluginResp, sigResp] = await Promise.all([
|
||||||
fetchWithTimeout(`${PLUGIN_BASE}/bin/plugin.js`),
|
fetchWithTimeout(`${GITEA_BASE}/com.pdma.notion-timer.sdPlugin/bin/plugin.js`),
|
||||||
fetchWithTimeout(`${PLUGIN_BASE}/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) { sendStatus?.("Download failed"); return; }
|
||||||
|
|
||||||
@@ -57,29 +52,26 @@ 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), "..");
|
||||||
|
|
||||||
// Also update UI and image assets. These are not separately signed — they run in a browser
|
|
||||||
// sandbox (not Node), and are fetched over HTTPS from the same trusted server.
|
|
||||||
const ASSETS = [
|
const ASSETS = [
|
||||||
"ui/property-inspector.html",
|
"ui/property-inspector.html",
|
||||||
"ui/global-property-inspector.html",
|
"ui/global-property-inspector.html",
|
||||||
"imgs/idle.png",
|
"imgs/idle.png",
|
||||||
"imgs/running.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}`)));
|
const assetResps = await Promise.all(ASSETS.map(p => fetchWithTimeout(`${PLUGIN_BASE}/${p}`)));
|
||||||
|
|
||||||
fs.writeFileSync(__filename, newCode);
|
|
||||||
for (let i = 0; i < ASSETS.length; i++) {
|
for (let i = 0; i < ASSETS.length; i++) {
|
||||||
if (!assetResps[i].ok) { streamDeck.logger.warn(`Asset download failed: ${ASSETS[i]}`); continue; }
|
if (assetResps[i].ok) {
|
||||||
fs.writeFileSync(path.join(pluginRoot, ASSETS[i]), Buffer.from(await assetResps[i].arrayBuffer()));
|
fs.writeFileSync(path.join(pluginRoot, ASSETS[i]), Buffer.from(await assetResps[i].arrayBuffer()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remove legacy files that were replaced in older versions but persist on disk
|
|
||||||
// because Stream Deck merges rather than replaces the plugin folder on reinstall.
|
|
||||||
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 */ }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
@@ -104,12 +96,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 = {
|
||||||
@@ -122,41 +114,42 @@ async function getGlobal(): Promise<GlobalSettings> {
|
|||||||
return { ...stored, ...HARDCODED };
|
return { ...stored, ...HARDCODED };
|
||||||
}
|
}
|
||||||
|
|
||||||
// In-memory cache so onWillAppear can check running state without an async round-trip
|
// In-memory running state — avoids async round-trips on every button press
|
||||||
let memRunningEntryId: string | null | undefined = undefined; // undefined = not yet loaded
|
let memRunningEntryId: string | null | undefined = undefined;
|
||||||
|
let memRunningActionId: string | null | undefined = undefined;
|
||||||
|
|
||||||
async function getRunningEntryId(): Promise<string | null> {
|
async function loadRunningState(): Promise<void> {
|
||||||
if (memRunningEntryId === undefined) {
|
if (memRunningEntryId !== undefined) return;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setRunningEntry(entryId: string | null): Promise<void> {
|
function setRunningEntry(entryId: string | null, actionId: string | null): void {
|
||||||
memRunningEntryId = entryId;
|
memRunningEntryId = entryId;
|
||||||
const stored = await streamDeck.settings.getGlobalSettings<GlobalSettings>();
|
memRunningActionId = actionId;
|
||||||
await streamDeck.settings.setGlobalSettings({ ...stored, runningEntryId: entryId });
|
// 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(overrideToken?: string): Promise<void> {
|
async function sendProjectsToPI(tokenOverride?: string): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const global = await getGlobal();
|
const global = await getGlobal();
|
||||||
const token = overrideToken || global.notionToken;
|
const token = tokenOverride ?? global.notionToken;
|
||||||
if (!token) {
|
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;
|
||||||
}
|
}
|
||||||
let usersResult: Awaited<ReturnType<typeof fetchUsers>> = [];
|
const [projects, usersResult] = await Promise.all([
|
||||||
let usersError: string | undefined;
|
|
||||||
const [projects] = await Promise.all([
|
|
||||||
fetchProjects(token, global.projectsDbId),
|
fetchProjects(token, global.projectsDbId),
|
||||||
fetchUsers(token).then((u) => { usersResult = u; }).catch((err) => {
|
fetchUsers(token).catch((err) => {
|
||||||
streamDeck.logger.error("Failed to fetch users:", err);
|
streamDeck.logger.error("Failed to fetch users:", err);
|
||||||
usersError = err instanceof Error ? err.message : String(err);
|
return [];
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
await streamDeck.ui.sendToPropertyInspector({ event: "projects", data: projects, users: usersResult, usersError, version: CURRENT_VERSION });
|
await streamDeck.ui.sendToPropertyInspector({ event: "projects", data: projects, users: usersResult, version: CURRENT_VERSION });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
streamDeck.logger.error("Failed to fetch projects:", err);
|
streamDeck.logger.error("Failed to fetch projects:", err);
|
||||||
await streamDeck.ui.sendToPropertyInspector({ event: "projects", data: [], error: String(err), version: CURRENT_VERSION });
|
await streamDeck.ui.sendToPropertyInspector({ event: "projects", data: [], error: String(err), version: CURRENT_VERSION });
|
||||||
@@ -167,102 +160,74 @@ 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 settingsCache = new Map<string, TimerSettings>();
|
private projectCache = new Map<string, TimerSettings>();
|
||||||
|
|
||||||
async onWillAppear(ev: WillAppearEvent<TimerSettings>): Promise<void> {
|
async onWillAppear(ev: WillAppearEvent<TimerSettings>): Promise<void> {
|
||||||
const { activeEntryId, projectName } = ev.payload.settings;
|
this.projectCache.set(ev.action.id, ev.payload.settings);
|
||||||
const title = buttonTitle(projectName || "");
|
const title = buttonTitle(ev.payload.settings.projectName || "");
|
||||||
|
await loadRunningState();
|
||||||
// Use in-memory cache to determine correct state before rendering — no flash
|
const isRunning = memRunningActionId === ev.action.id;
|
||||||
const running = await getRunningEntryId();
|
|
||||||
const isRunning = !!activeEntryId && activeEntryId === running;
|
|
||||||
|
|
||||||
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)]);
|
|
||||||
} else {
|
|
||||||
this.settingsCache.set(ev.action.id, ev.payload.settings);
|
|
||||||
if (isRunning) {
|
if (isRunning) {
|
||||||
await Promise.all([ev.action.setState(1), ev.action.setTitle(`⏱ ${title}`)]);
|
await Promise.all([ev.action.setState(1), ev.action.setTitle(`⏱ ${title}`)]);
|
||||||
} else {
|
} else {
|
||||||
await Promise.all([ev.action.setState(0), ev.action.setTitle(title)]);
|
await Promise.all([ev.action.setState(0), ev.action.setTitle(title)]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
async onPropertyInspectorDidAppear(_ev: PropertyInspectorDidAppearEvent<TimerSettings>): Promise<void> {
|
async onPropertyInspectorDidAppear(_ev: PropertyInspectorDidAppearEvent<TimerSettings>): Promise<void> {
|
||||||
await sendProjectsToPI();
|
await sendProjectsToPI();
|
||||||
}
|
}
|
||||||
|
|
||||||
async onKeyDown(ev: KeyDownEvent<TimerSettings>): Promise<void> {
|
async onKeyDown(ev: KeyDownEvent<TimerSettings>): Promise<void> {
|
||||||
this.settingsCache.set(ev.action.id, ev.payload.settings);
|
const { projectId, projectName } = 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;
|
||||||
|
|
||||||
if (!isConfigured(global)) {
|
// Instant visual feedback — no setSettings, no flash
|
||||||
await ev.action.showAlert();
|
if (projectId) {
|
||||||
return;
|
if (isRunning) {
|
||||||
}
|
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 {
|
||||||
const prevEntryId = await getRunningEntryId();
|
|
||||||
|
|
||||||
// Stop previous timer
|
|
||||||
if (prevEntryId) {
|
|
||||||
await stopTimer(global.notionToken, prevEntryId);
|
|
||||||
for (const other of this.actions) {
|
for (const other of this.actions) {
|
||||||
if (other.id === ev.action.id) continue;
|
if (other.id === ev.action.id) continue;
|
||||||
const otherSettings = this.settingsCache.get(other.id);
|
if (memRunningActionId === other.id) {
|
||||||
if (otherSettings?.activeEntryId === prevEntryId) {
|
const s = this.projectCache.get(other.id);
|
||||||
const stopped = { ...otherSettings, activeEntryId: null };
|
await Promise.all([other.setState(0), other.setTitle(buttonTitle(s?.projectName || ""))]);
|
||||||
await other.setSettings(stopped);
|
|
||||||
this.settingsCache.set(other.id, stopped);
|
|
||||||
await other.setState(0);
|
|
||||||
await other.setTitle(buttonTitle(otherSettings.projectName || ""));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
await Promise.all([ev.action.setState(1), ev.action.setTitle(`⏱ ${title}`)]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const entryId = await startTimer(
|
const global = await getGlobal();
|
||||||
global.notionToken,
|
if (!isConfigured(global)) { await ev.action.showAlert(); return; }
|
||||||
global.timingDbId,
|
if (!projectId) { await ev.action.showAlert(); return; }
|
||||||
projectId,
|
|
||||||
projectName,
|
try {
|
||||||
global.userId,
|
if (isRunning) {
|
||||||
);
|
await stopTimer(global.notionToken, memRunningEntryId!);
|
||||||
const started = { ...ev.payload.settings, activeEntryId: entryId };
|
setRunningEntry(null, null);
|
||||||
await ev.action.setSettings(started);
|
await Promise.all([ev.action.setState(0), ev.action.setTitle(title)]);
|
||||||
this.settingsCache.set(ev.action.id, started);
|
} else {
|
||||||
await setRunningEntry(entryId);
|
if (memRunningEntryId) {
|
||||||
await ev.action.setState(1);
|
await stopTimer(global.notionToken, memRunningEntryId);
|
||||||
await ev.action.setTitle(`⏱ ${title}`);
|
}
|
||||||
|
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}`)]);
|
||||||
}
|
}
|
||||||
} 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();
|
||||||
}
|
}
|
||||||
@@ -272,15 +237,14 @@ 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 }>(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 === "refresh") {
|
if (ev.payload.event === "refreshProjects") {
|
||||||
await sendProjectsToPI(ev.payload.notionToken as string | undefined);
|
await sendProjectsToPI(ev.payload.token);
|
||||||
}
|
}
|
||||||
if (ev.payload.event === "checkForUpdates") {
|
if (ev.payload.event === "checkForUpdates") {
|
||||||
const send = (msg: string) => streamDeck.ui.sendToPropertyInspector({ event: "updateStatus", message: msg });
|
const send = (msg: string) => streamDeck.ui.sendToPropertyInspector({ event: "updateStatus", message: msg });
|
||||||
@@ -291,5 +255,4 @@ streamDeck.ui.onSendToPlugin<{ event: string; settings?: TimerSettings }>(async
|
|||||||
|
|
||||||
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.26" }
|
{ "version": "1.0.39" }
|
||||||
|
|||||||
Reference in New Issue
Block a user