v1.0.5: user dropdown from Notion API, settingsCache pruning

This commit is contained in:
pdmarf
2026-04-10 20:42:11 +01:00
parent 2029b5187e
commit d6282d7396
6 changed files with 82 additions and 34 deletions

View File

@@ -39,12 +39,29 @@ function notionIconToEmoji(page: any): string {
if (icon.type === "icon") {
const { name, color } = icon.icon ?? {};
if (name === "book") return BOOK_COLOR[color] ?? "📚";
if (name === "skip-forward") return `${COLOR_CIRCLE[color] ?? ""}`.trimEnd();
if (name === "skip-forward") return "⏭";
return ICON_NAME[name] ?? "";
}
return "";
}
export interface NotionUser {
id: string;
name: string;
}
export async function fetchUsers(token: string): Promise<NotionUser[]> {
const resp = await fetch(`${NOTION_BASE}/users`, {
headers: headers(token),
});
if (!resp.ok) throw new Error(`Failed to fetch users: ${resp.status}`);
const data = (await resp.json()) as { results: any[] };
return data.results
.filter((u: any) => u.type === "person" && u.person?.email)
.map((u: any) => ({ id: u.id as string, name: u.name as string }))
.sort((a, b) => a.name.localeCompare(b.name));
}
export async function fetchProjects(token: string, dbId: string): Promise<NotionProject[]> {
const resp = await fetch(`${NOTION_BASE}/databases/${dbId}/query`, {
method: "POST",