v1.0.5: user dropdown from Notion API, settingsCache pruning
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const CURRENT_VERSION = "1.0.4";
|
||||
const CURRENT_VERSION = "1.0.5";
|
||||
const GITEA_BASE = "http://100.120.125.113:3000/pdm/stream_deck_notion_timer/raw/branch/master";
|
||||
const SIGNING_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
|
||||
MCowBQYDK2VwAyEAN7ko8TUpuPzPAJuKAZCRjV0c4ZSlou5d9pUAF6o12b4=
|
||||
@@ -53,7 +53,7 @@ import streamDeck, {
|
||||
SingletonAction,
|
||||
WillAppearEvent,
|
||||
} from "@elgato/streamdeck";
|
||||
import { fetchProjects, startTimer, stopTimer } from "./notion.js";
|
||||
import { fetchProjects, fetchUsers, startTimer, stopTimer } from "./notion.js";
|
||||
|
||||
interface GlobalSettings {
|
||||
notionToken: string;
|
||||
@@ -91,6 +91,10 @@ function buttonTitle(projectName: string): string {
|
||||
class TimerToggle extends SingletonAction<TimerSettings> {
|
||||
private settingsCache = new Map<string, TimerSettings>();
|
||||
|
||||
async onWillDisappear(ev: WillAppearEvent<TimerSettings>): Promise<void> {
|
||||
this.settingsCache.delete(ev.action.id);
|
||||
}
|
||||
|
||||
async onWillAppear(ev: WillAppearEvent<TimerSettings>): Promise<void> {
|
||||
this.settingsCache.set(ev.action.id, ev.payload.settings);
|
||||
const { activeEntryId, projectName } = ev.payload.settings;
|
||||
@@ -109,8 +113,11 @@ class TimerToggle extends SingletonAction<TimerSettings> {
|
||||
await streamDeck.ui.sendToPropertyInspector({ event: "projects", data: [], error: "Configure Notion credentials in plugin settings first.", version: CURRENT_VERSION });
|
||||
return;
|
||||
}
|
||||
const projects = await fetchProjects(global.notionToken, global.projectsDbId);
|
||||
await streamDeck.ui.sendToPropertyInspector({ event: "projects", data: projects, version: CURRENT_VERSION });
|
||||
const [projects, users] = await Promise.all([
|
||||
fetchProjects(global.notionToken, global.projectsDbId),
|
||||
fetchUsers(global.notionToken),
|
||||
]);
|
||||
await streamDeck.ui.sendToPropertyInspector({ event: "projects", data: projects, users, version: CURRENT_VERSION });
|
||||
} catch (err) {
|
||||
streamDeck.logger.error("Failed to fetch projects:", err);
|
||||
await streamDeck.ui.sendToPropertyInspector({ event: "projects", data: [], error: String(err), version: CURRENT_VERSION });
|
||||
|
||||
Reference in New Issue
Block a user