Some checks failed
E2E / Playwright e2e (push) Has been cancelled
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.
33 lines
733 B
TypeScript
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,
|
|
}
|
|
}
|