From 99ce586afaa1277fbdd95087a6cc46b6649b2136 Mon Sep 17 00:00:00 2001 From: Thibault Coupin Date: Tue, 25 Feb 2025 20:59:36 +0100 Subject: [PATCH] webdav mime is optional --- .../lib/getNodeIconType.ts | 42 +++++++++---------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/apps/meteor/client/views/room/webdav/WebdavFilePickerModal/lib/getNodeIconType.ts b/apps/meteor/client/views/room/webdav/WebdavFilePickerModal/lib/getNodeIconType.ts index 13c9e506dab0c..137102294c704 100644 --- a/apps/meteor/client/views/room/webdav/WebdavFilePickerModal/lib/getNodeIconType.ts +++ b/apps/meteor/client/views/room/webdav/WebdavFilePickerModal/lib/getNodeIconType.ts @@ -13,31 +13,29 @@ export const getNodeIconType = ( extension = ''; } - if (!mime) { - throw new Error('mime is required'); - } - if (fileType === 'directory') { icon = 'folder'; type = 'directory'; - } else if (mime.match(/application\/pdf/)) { - icon = 'file-pdf'; - type = 'pdf'; - } else if (['application/vnd.oasis.opendocument.text', 'application/vnd.oasis.opendocument.presentation'].includes(mime)) { - icon = 'file-document'; - type = 'document'; - } else if ( - [ - 'application/vnd.ms-excel', - 'application/vnd.oasis.opendocument.spreadsheet', - 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', - ].includes(mime) - ) { - icon = 'file-sheets'; - type = 'sheets'; - } else if (['application/vnd.ms-powerpoint', 'application/vnd.oasis.opendocument.presentation'].includes(mime)) { - icon = 'file-sheets'; - type = 'ppt'; + } else if (mime) { + if (mime.match(/application\/pdf/)) { + icon = 'file-pdf'; + type = 'pdf'; + } else if (['application/vnd.oasis.opendocument.text', 'application/vnd.oasis.opendocument.presentation'].includes(mime)) { + icon = 'file-document'; + type = 'document'; + } else if ( + [ + 'application/vnd.ms-excel', + 'application/vnd.oasis.opendocument.spreadsheet', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + ].includes(mime) + ) { + icon = 'file-sheets'; + type = 'sheets'; + } else if (['application/vnd.ms-powerpoint', 'application/vnd.oasis.opendocument.presentation'].includes(mime)) { + icon = 'file-sheets'; + type = 'ppt'; + } } return { icon, type, extension }; };