diff --git a/web/src/features/mailbox/components/mail-list.tsx b/web/src/features/mailbox/components/mail-list.tsx index a5279e8..91ae65f 100644 --- a/web/src/features/mailbox/components/mail-list.tsx +++ b/web/src/features/mailbox/components/mail-list.tsx @@ -1,9 +1,3 @@ -/* - * Copyright © 2025 rustmailer.com - * Licensed under RustMailer License Agreement v1.0 - * Unauthorized use or distribution is prohibited. - */ - import { cn, formatFileSize } from "@/lib/utils" import { Badge } from "@/components/ui/badge" import { formatDistanceToNow } from "date-fns" @@ -14,14 +8,14 @@ import { Checkbox } from "@/components/ui/checkbox" import { MailboxDialogType } from "../context" interface MailListProps { - items: EmailEnvelope[], + items: EmailEnvelope[] isLoading: boolean currentEnvelope: EmailEnvelope | undefined onEnvelopeChanged: (envelope: EmailEnvelope) => void - setOpen: (str: MailboxDialogType | null) => void, - setSelectedIds: React.Dispatch>; - setDeleteIds: React.Dispatch>; - selectedIds: string[]; + setOpen: (str: MailboxDialogType | null) => void + setSelectedIds: React.Dispatch> + setDeleteIds: React.Dispatch> + selectedIds: string[] } export function MailList({ @@ -35,31 +29,26 @@ export function MailList({ selectedIds }: MailListProps) { const handleDelete = (envelope: EmailEnvelope) => { - setDeleteIds([envelope.id]); - setOpen("move-to-trash"); + setDeleteIds([envelope.id]) + setOpen("move-to-trash") } const handleCheckboxChange = (value: boolean | 'indeterminate', id: string) => { if (value === true) { - setSelectedIds((prev) => [...prev, id]); + setSelectedIds(prev => [...prev, id]) } else if (value === false) { - setSelectedIds((prev) => prev.filter((x) => x !== id)); + setSelectedIds(prev => prev.filter(x => x !== id)) } - }; + } if (isLoading) { return ( -
- {Array.from({ length: 8 }).map((_, index) => ( -
-
- - - -
-
- -
+
+ {Array.from({ length: 8 }).map((_, i) => ( +
+ + +
))}
@@ -67,135 +56,105 @@ export function MailList({ } return ( - -
+
{items.map((item) => { - const isUnread = !item.is_read; + const isUnread = !item.is_read const hasAttachments = item.attachments && item.attachments.length > 0; - const attachmentCount = item.attachments?.length || 0; + const isSelected = selectedIds.includes(item.id) + const isActive = currentEnvelope?.id === item.id return (
onEnvelopeChanged(item)} > -
- { - handleCheckboxChange(checked, item.id) - }} - onClick={(e) => e.stopPropagation()} - className="h-4 w-3 shrink-0" - /> + {/* Checkbox */} + handleCheckboxChange(checked, item.id)} + onClick={(e) => e.stopPropagation()} + className="h-3.5 w-3.5 shrink-0" + /> -
- {isUnread ? ( - - ) : ( - - )} - {/* - {isGmailApi ? `mid: ${item.id}` : `uid: ${item.id}`} - */} + {/* Unread Icon */} + {isUnread ? ( + + ) : ( + + )} -

- {item.from ? `${item.from.name || ""} <${item.from.address}>` : "Unknown"} -

+ {/* Sender */} + + {item.from?.name || item.from?.address || "Unknown"} + - {isUnread && ( - - )} -
- -
- {hasAttachments && ( -
- - - {attachmentCount} - -
- )} - - - {formatFileSize(item.size)} - - - - {item.date && formatDistanceToNow(new Date(item.date), { - addSuffix: true, - })} - -
-
- -
-

+ {/* Subject + Attachments */} +
+ {hasAttachments && ( + + )} + {item.subject || "(No Subject)"} -

+
-
-
- {item.flags?.map((flag) => ( - - {isCustomFlag(flag.flag) ? flag.custom : flag.flag} - - ))} - {item.labels?.length > 0 && - item.labels.map((label) => ( - - {label} - - ))} -
- + {/* Flags / Labels */} +
+ {item.flags?.slice(0, 2).map((flag) => ( + + {isCustomFlag(flag.flag) ? flag.custom : flag.flag} + + ))} + {item.labels?.[0] && ( + + {item.labels[0]} + + )} + {(item.flags?.length ?? 0) > 2 || item.labels?.length > 1 ? ( + +{((item.flags?.length ?? 0) - 2) + (item.labels?.length - 1)} + ) : null}
+ + {/* Size & Time */} + + {formatFileSize(item.size)} + + + {item.date && formatDistanceToNow(new Date(item.date), { addSuffix: true })} + + + {/* Delete Button */} +
- ); + ) })}
- ); + ) } \ No newline at end of file diff --git a/web/src/features/mailbox/components/mail.tsx b/web/src/features/mailbox/components/mail.tsx index bbe9c96..bc46ad0 100644 --- a/web/src/features/mailbox/components/mail.tsx +++ b/web/src/features/mailbox/components/mail.tsx @@ -177,7 +177,7 @@ export function Mail({ const pageTokenMapRef = React.useRef>({}); const [page, setPage] = React.useState(0); - const [pageSize, setPageSize] = React.useState(10); + const [pageSize, setPageSize] = React.useState(30); const [selectedIds, setSelectedIds] = React.useState([]); const [deleteIds, setDeleteIds] = React.useState([]); const [currentFilter, setCurrentFilter] = React.useState(undefined);