fix(ui): compact Office attachment context

This commit is contained in:
Bohdan Triapitsyn
2026-08-18 19:54:16 +03:00
parent 1efc7fb570
commit 215749a65f
7 changed files with 257 additions and 85 deletions
+3 -1
View File
@@ -217,6 +217,8 @@ const extensionOf = (name: string): string => {
return index === -1 ? "" : name.slice(index + 1).toLowerCase()
}
export const isDocumentAttachmentFilename = (name: string): boolean => DOCUMENT_EXTENSIONS.has(extensionOf(name))
const declaredMimeOf = (file: File): string => file.type.split(";", 1)[0]?.trim().toLowerCase() ?? ""
const inspectTextContent = async (file: File): Promise<"text/plain" | undefined> => {
@@ -392,7 +394,7 @@ export const prepareAttachmentFiles = (
file: File,
reservedFilenames: Iterable<string> = [],
): PreparedAttachmentFile[] | Promise<PreparedAttachmentFile[] | undefined> | undefined => {
if (!DOCUMENT_EXTENSIONS.has(extensionOf(file.name))) {
if (!isDocumentAttachmentFilename(file.name)) {
const prepared = prepareAttachmentFile(file)
if (prepared instanceof Promise) return prepared.then((output) => output ? [output] : undefined)
return prepared ? [prepared] : undefined