diff --git a/packages/presentation/src/file.ts b/packages/presentation/src/file.ts index 493ac4411dc..2de465c1361 100644 --- a/packages/presentation/src/file.ts +++ b/packages/presentation/src/file.ts @@ -285,10 +285,10 @@ async function uploadFileWithSignedUrl (file: File, uuid: string, uploadUrl: str } } -export async function getJsonOrEmpty (file: string, name: string, timeoutMs = 3000): Promise { +export async function getJsonOrEmpty (file: string, name: string): Promise { try { const fileUrl = getFileUrl(file, name) - const resp = await fetch(fileUrl, { signal: AbortSignal.timeout(timeoutMs) }) + const resp = await fetch(fileUrl) return await resp.json() } catch { return [] diff --git a/packages/presentation/src/link-preview.ts b/packages/presentation/src/link-preview.ts index a1c0aeabed6..dfda911da2f 100644 --- a/packages/presentation/src/link-preview.ts +++ b/packages/presentation/src/link-preview.ts @@ -48,13 +48,8 @@ export async function fetchLinkPreviewDetails (url: string, timeoutMs = 15000): const response = await fetch(`${linkPreviewUrl}?q=${url}`, { signal: AbortSignal.timeout(timeoutMs) }) - if (!response.ok) { - throw new Error(`status: ${response.status}`) - } - console.log(response) return response.json() as LinkPreviewDetails - } catch (error) { - console.error(`An error occurced on fetching or parsing data by ${url}, error:`, error) + } catch { return {} } } diff --git a/plugins/attachment-resources/src/components/AttachmentGroup.svelte b/plugins/attachment-resources/src/components/AttachmentGroup.svelte index 58ffd927006..10f76e818cf 100644 --- a/plugins/attachment-resources/src/components/AttachmentGroup.svelte +++ b/plugins/attachment-resources/src/components/AttachmentGroup.svelte @@ -1,3 +1,18 @@ + + -
+
{#if viewModel} -
+
{#if viewModel.icon !== undefined && !useDefaultIcon} link-preview + + link-preview + {/if}
@@ -74,9 +76,10 @@ diff --git a/plugins/attachment-resources/src/utils.ts b/plugins/attachment-resources/src/utils.ts index 4ea951480fc..147373c1038 100644 --- a/plugins/attachment-resources/src/utils.ts +++ b/plugins/attachment-resources/src/utils.ts @@ -101,16 +101,16 @@ export function getType ( if (type.startsWith('video/')) { return 'video' } - if (type === 'application/pdf') { + if (type.includes('application/pdf')) { return 'pdf' } - if (type === 'application/json') { + if (type.includes('application/json')) { return 'json' } if (type.startsWith('text/')) { return 'text' } - if (type === 'application/link-preview') { + if (type.includes('application/link-preview')) { return 'link-preview' } return 'other'