Files
webmail/lib/compose/attachment-order.ts
T
Linus Rath 2b2b7b8298 fix: show every attachment in the composer, with type icons and a total, failed and uploading files first
The attachment list test now expects every chip and a bounded, scrolling row instead of three chips and a +N counter.
2026-11-04 09:01:04 +01:00

15 lines
673 B
TypeScript

/**
* The composer's attachment chips in the order they're shown: failed first,
* then still uploading, then the rest, each group in the order added. The
* list scrolls past about two rows, so the files that need an eye on them
* are the ones always in view. `index` is the place in the composer's list.
*/
export function attachmentsForDisplay<T extends { error?: unknown; uploading?: boolean }>(
attachments: readonly T[],
): Array<{ att: T; index: number }> {
const rank = (att: T) => (att.error ? 0 : att.uploading ? 1 : 2);
return attachments
.map((att, index) => ({ att, index }))
.sort((a, b) => rank(a.att) - rank(b.att) || a.index - b.index);
}