feat: add unified mailbox across accounts and sidebar icons toggle
This commit is contained in:
+35
-1
@@ -1,6 +1,7 @@
|
||||
import { type ClassValue, clsx } from "clsx";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
import { Mailbox } from "./jmap/types";
|
||||
import { Mailbox, UNIFIED_MAILBOX_IDS } from "./jmap/types";
|
||||
import type { UnifiedMailboxRole } from "./jmap/types";
|
||||
import { debug } from "./debug";
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
@@ -380,6 +381,39 @@ export function buildMailboxTree(mailboxes: Mailbox[]): MailboxNode[] {
|
||||
return rootMailboxes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds virtual MailboxNode entries for unified mailbox roles with aggregated counts.
|
||||
*/
|
||||
export function buildUnifiedMailboxNodes(
|
||||
counts: Array<{ role: UnifiedMailboxRole; unreadEmails: number; totalEmails: number }>,
|
||||
): MailboxNode[] {
|
||||
return counts.map((count) => ({
|
||||
id: UNIFIED_MAILBOX_IDS[count.role],
|
||||
name: count.role, // Display name is handled by i18n in the component
|
||||
role: count.role,
|
||||
parentId: undefined,
|
||||
sortOrder: 0,
|
||||
totalEmails: count.totalEmails,
|
||||
unreadEmails: count.unreadEmails,
|
||||
totalThreads: 0,
|
||||
unreadThreads: 0,
|
||||
myRights: {
|
||||
mayReadItems: true,
|
||||
mayAddItems: false,
|
||||
mayRemoveItems: false,
|
||||
maySetSeen: true,
|
||||
maySetKeywords: true,
|
||||
mayCreateChild: false,
|
||||
mayRename: false,
|
||||
mayDelete: false,
|
||||
maySubmit: false,
|
||||
},
|
||||
isSubscribed: true,
|
||||
children: [],
|
||||
depth: 0,
|
||||
}));
|
||||
}
|
||||
|
||||
// Flatten a mailbox tree for rendering with proper depth info
|
||||
export function flattenMailboxTree(nodes: MailboxNode[]): MailboxNode[] {
|
||||
const result: MailboxNode[] = [];
|
||||
|
||||
Reference in New Issue
Block a user