v1.0.27: auto-load projects/users after API token is entered
Previously staff had to close and reopen the property inspector after entering their token to trigger the fetch. Now saving the token immediately sends a refreshProjects event to the plugin, which fetches and returns the project list and name dropdown. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -6438,7 +6438,7 @@ async function stopTimer(token, entryId) {
|
||||
}
|
||||
|
||||
// src/plugin.ts
|
||||
var CURRENT_VERSION = "1.0.26";
|
||||
var CURRENT_VERSION = "1.0.27";
|
||||
var GITEA_BASE = "https://gitea.pdmarf.co.uk/pdm/stream_deck_notion_timer/raw/branch/stable-rebuild";
|
||||
var SIGNING_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
|
||||
MCowBQYDK2VwAyEAN7ko8TUpuPzPAJuKAZCRjV0c4ZSlou5d9pUAF6o12b4=
|
||||
@@ -6518,6 +6518,27 @@ async function setRunningEntry(entryId) {
|
||||
const stored = await plugin_default.settings.getGlobalSettings();
|
||||
await plugin_default.settings.setGlobalSettings({ ...stored, runningEntryId: entryId });
|
||||
}
|
||||
async function sendProjectsToPI(tokenOverride) {
|
||||
try {
|
||||
const global = await getGlobal();
|
||||
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 });
|
||||
return;
|
||||
}
|
||||
const [projects, usersResult] = await Promise.all([
|
||||
fetchProjects(token, global.projectsDbId),
|
||||
fetchUsers(token).catch((err) => {
|
||||
plugin_default.logger.error("Failed to fetch users:", err);
|
||||
return [];
|
||||
})
|
||||
]);
|
||||
await plugin_default.ui.sendToPropertyInspector({ event: "projects", data: projects, users: usersResult, version: CURRENT_VERSION });
|
||||
} catch (err) {
|
||||
plugin_default.logger.error("Failed to fetch projects:", err);
|
||||
await plugin_default.ui.sendToPropertyInspector({ event: "projects", data: [], error: String(err), version: CURRENT_VERSION });
|
||||
}
|
||||
}
|
||||
function isConfigured(g) {
|
||||
return !!(g.notionToken && g.userId);
|
||||
}
|
||||
@@ -6545,25 +6566,8 @@ var TimerToggle = class extends SingletonAction {
|
||||
}
|
||||
}
|
||||
}
|
||||
async onPropertyInspectorDidAppear(ev) {
|
||||
try {
|
||||
const global = await getGlobal();
|
||||
if (!global.notionToken) {
|
||||
await plugin_default.ui.sendToPropertyInspector({ event: "projects", data: [], error: "Enter your Notion API token above.", version: CURRENT_VERSION });
|
||||
return;
|
||||
}
|
||||
const [projects, usersResult] = await Promise.all([
|
||||
fetchProjects(global.notionToken, global.projectsDbId),
|
||||
fetchUsers(global.notionToken).catch((err) => {
|
||||
plugin_default.logger.error("Failed to fetch users:", err);
|
||||
return [];
|
||||
})
|
||||
]);
|
||||
await plugin_default.ui.sendToPropertyInspector({ event: "projects", data: projects, users: usersResult, version: CURRENT_VERSION });
|
||||
} catch (err) {
|
||||
plugin_default.logger.error("Failed to fetch projects:", err);
|
||||
await plugin_default.ui.sendToPropertyInspector({ event: "projects", data: [], error: String(err), version: CURRENT_VERSION });
|
||||
}
|
||||
async onPropertyInspectorDidAppear(_ev) {
|
||||
await sendProjectsToPI();
|
||||
}
|
||||
async onKeyDown(ev) {
|
||||
this.settingsCache.set(ev.action.id, ev.payload.settings);
|
||||
@@ -6640,6 +6644,9 @@ plugin_default.ui.onSendToPlugin(async (ev) => {
|
||||
const title = buttonTitle(ev.payload.settings.projectName || "");
|
||||
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");
|
||||
|
||||
Binary file not shown.
@@ -2,7 +2,7 @@
|
||||
"Author": "Pete Marfleet",
|
||||
"Description": "Toggle Notion time tracking for a project with a single button press.",
|
||||
"Name": "Notion Timer",
|
||||
"Version": "1.0.26",
|
||||
"Version": "1.0.27",
|
||||
"SDKVersion": 2,
|
||||
"Software": { "MinimumVersion": "5.0" },
|
||||
"OS": [{ "Platform": "mac", "MinimumVersion": "10.11" }],
|
||||
|
||||
@@ -194,6 +194,10 @@
|
||||
};
|
||||
$PI.setGlobalSettings(creds);
|
||||
setCredStatus("Credentials saved.", "ok");
|
||||
if (creds.notionToken) {
|
||||
setStatus("Loading…", "");
|
||||
$PI.sendToPlugin({ event: "refreshProjects", token: creds.notionToken });
|
||||
}
|
||||
}
|
||||
|
||||
function populateUsers(users, savedUserId) {
|
||||
|
||||
Reference in New Issue
Block a user