v1.0.5: user dropdown from Notion API, settingsCache pruning
This commit is contained in:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user