From 2f4f9803b9c89454e0342a9a11f567895663510d Mon Sep 17 00:00:00 2001 From: Agent Zero Date: Thu, 30 Jul 2026 18:03:48 +0200 Subject: [PATCH] fix: mail grouping collapsible groups, no sticky header, recursive subgroups with all mails --- frontend/src/components/mail/MailList.tsx | 105 ++++++++++++++++------ 1 file changed, 78 insertions(+), 27 deletions(-) diff --git a/frontend/src/components/mail/MailList.tsx b/frontend/src/components/mail/MailList.tsx index fc14248..3692c09 100644 --- a/frontend/src/components/mail/MailList.tsx +++ b/frontend/src/components/mail/MailList.tsx @@ -9,9 +9,10 @@ import { useTranslation } from 'react-i18next'; import type { Mail } from '@/api/mail'; import { decodeMimeHeader } from '@/api/mail'; import { EmptyState } from '@/components/ui/EmptyState'; -import { Loader2, Paperclip, Star, ChevronDown } from 'lucide-react'; +import { Loader2, Paperclip, Star, ChevronDown, ChevronRight } from 'lucide-react'; import { formatSmartDate } from '@/utils/date'; import type { GroupedMails } from '@/components/mail/MailGroupPanel'; +import type { Mail } from '@/api/mail'; export interface MailListProps { mails: Mail[]; @@ -30,6 +31,73 @@ function formatDate(dateStr: string): string { return formatSmartDate(dateStr) || dateStr; } +// Collapsible group section for grouped mail display +function GroupSection({ + group, + level = 0, + selectedMailId, + selectedMailIds, + onSelectMail, + onToggleSelect, + renderMailItem, +}: { + group: GroupedMails; + level?: number; + selectedMailId: string | null; + selectedMailIds: Set; + onSelectMail: (mail: Mail) => void; + onToggleSelect: (mailId: string) => void; + renderMailItem: (mail: Mail) => React.ReactNode; +}) { + const [collapsed, setCollapsed] = useState(false); + const hasSubGroups = group.subGroups && group.subGroups.length > 0; + // Count total mails including subGroups + const totalCount = hasSubGroups + ? group.subGroups!.reduce((sum, sub) => sum + sub.mails.length, 0) + : group.mails.length; + + return ( +
  • +
    setCollapsed(!collapsed)} + > + {collapsed ? ( + + ) : ( + + )} + {group.label} + ({totalCount}) +
    + {!collapsed && ( + <> +
      + {group.mails.map((mail) => renderMailItem(mail))} +
    + {hasSubGroups && ( +
      + {group.subGroups!.map((sub) => ( + + ))} +
    + )} + + )} +
  • + ); +} + export function MailList({ mails, groupedMails, @@ -174,32 +242,15 @@ export function MailList({ > {groupedMails && groupedMails.length > 0 ? ( groupedMails.map((group) => ( -
  • -
    - - {group.label} - ({group.mails.length}) -
    -
      - {group.mails.map((mail) => renderMailItem(mail))} -
    - {group.subGroups && group.subGroups.length > 0 && ( -
      - {group.subGroups.map((sub) => ( -
    • -
      - - {sub.label} - ({sub.mails.length}) -
      -
        - {sub.mails.map((mail) => renderMailItem(mail))} -
      -
    • - ))} -
    - )} -
  • + )) ) : ( mails.map((mail) => renderMailItem(mail))