From c268e857934a7be6e4609c013f2c8facdee8769d Mon Sep 17 00:00:00 2001 From: Julius Knorr Date: Fri, 29 May 2026 09:27:07 +0200 Subject: [PATCH] fix: Search for all office file types The file creators only advertise one file format they create, so we need to extend the list so that all office mimes can be found Signed-off-by: Julius Knorr --- css/office-main.css | 2 +- src/views/OfficeOverview.vue | 25 +++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/css/office-main.css b/css/office-main.css index c0fda31..edac3d8 100644 --- a/css/office-main.css +++ b/css/office-main.css @@ -1,2 +1,2 @@ /* extracted by css-entry-points-plugin */ -@import './main-ChrxhTd_.chunk.css'; \ No newline at end of file +@import './main-C6G5yYHl.chunk.css'; \ No newline at end of file diff --git a/src/views/OfficeOverview.vue b/src/views/OfficeOverview.vue index a5696a3..8f623fa 100644 --- a/src/views/OfficeOverview.vue +++ b/src/views/OfficeOverview.vue @@ -58,6 +58,12 @@ const MIME_CATEGORIES: Record = { 'application/vnd.oasis.opendocument.graphics-template': t('office', 'Diagrams'), } +// Every office mimetype we can open, regardless of the configured create format +// (doc_format). richdocuments only advertises the create-format mimes per creator +// (e.g. OOXML when doc_format=ooxml), so we drive the search and category filtering +// from this full set instead — otherwise existing ODF files would never be found. +const ALL_OFFICE_MIMES = Object.keys(MIME_CATEGORIES) + const currentUid = getCurrentUser()?.uid ?? null const creators = ref([]) @@ -92,7 +98,7 @@ const searchLabel = computed(() => const filteredFiles = computed(() => { if (!activeCreator.value) return [] - const byCategory = filterByMimes(allFiles.value, activeCreator.value.mimetypes) + const byCategory = filterByMimes(allFiles.value, categoryMimes(activeCreator.value)) let filtered = byCategory if (activeFilter.value === 'mine') { @@ -130,6 +136,16 @@ function categoryName(creator: TemplateCreator): string { return creator.label } +// All mimetypes belonging to the creator's category (both ODF and OOXML), so a +// category shows every openable file regardless of the configured create format. +// The creator's own mimes are always kept, so anything it advertises beyond our +// static map (and any creator mapping to no known category) is still covered. +function categoryMimes(creator: TemplateCreator): string[] { + const category = categoryName(creator) + const fromCategory = ALL_OFFICE_MIMES.filter(mime => MIME_CATEGORIES[mime] === category) + return [...new Set([...fromCategory, ...creator.mimetypes])] +} + function setCreator(creator: TemplateCreator) { activeCreator.value = creator } @@ -234,7 +250,12 @@ async function fetchAll() { activeCreator.value = creators.value[0] ?? null if (creators.value.length > 0) { - const allMimes = creators.value.flatMap(c => c.mimetypes) + // Union our full static set (ODF + OOXML) with whatever the creators + // actually advertise, so we never drop a mime the server supports. + const allMimes = [...new Set([ + ...ALL_OFFICE_MIMES, + ...creators.value.flatMap(c => c.mimetypes), + ])] allFiles.value = await getAllOfficeFiles(allMimes) } } catch {