ultisuite-client/components/gmail/email-list/list-mail-index.ts
R3D347HR4Y c87670e90f
Some checks failed
E2E / Playwright e2e (push) Has been cancelled
feat(api): offline-first mail sync w/ TanStack Query
Move mail, compose, contacts, and accounts off mocks onto REST + WS.
Add client, auth store, IDB-backed query cache, offline queue, and
sync bar; hybrid Zustand for UI-only state. Settings still local until
backend has preferences API.
2026-05-23 00:04:28 +02:00

33 lines
733 B
TypeScript

"use client"
import type { Email } from "@/lib/email-data"
export type ListMailIndex = {
emailById: Map<string, Email>
scheduledIds: Set<string>
}
export function buildListMailIndex(emails: Email[]): ListMailIndex {
const emailById = new Map<string, Email>()
const scheduledIds = new Set<string>()
for (const e of emails) {
emailById.set(e.id, e)
if (e.labels?.includes("scheduled")) scheduledIds.add(e.id)
}
return { emailById, scheduledIds }
}
export type MailRowFlags = {
isRead: boolean
isStarred: boolean
isImportant: boolean
}
export function useMailRowFlags(email: Email): MailRowFlags {
return {
isRead: email.read,
isStarred: email.starred,
isImportant: email.important,
}
}