Apply feedback improvements: UBERF-9189 (#7778)
Some checks are pending
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions

This commit is contained in:
Denis Tingaikin 2025-01-24 03:50:56 +03:00 committed by GitHub
parent f82bf77a08
commit 992bc99cea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 17 additions and 12 deletions

View File

@ -33,10 +33,10 @@ export function canDisplayLinkPreview (val: LinkPreviewDetails): boolean {
if (val.hostname === undefined) { if (val.hostname === undefined) {
return false return false
} }
if (val.image === undefined && val.description === undefined) { if (val.image === undefined && val.description?.trim() === '') {
return false return false
} }
if (val.title === undefined && val.description === undefined) { if (val.title?.trim() === '' && val.description?.trim() === '') {
return false return false
} }
return true return true
@ -53,7 +53,9 @@ export async function fetchLinkPreviewDetails (url: string, timeoutMs = 15000):
headers: { Authorization: 'Bearer ' + token }, headers: { Authorization: 'Bearer ' + token },
signal: AbortSignal.timeout(timeoutMs) signal: AbortSignal.timeout(timeoutMs)
}) })
return response.json() as LinkPreviewDetails const res = (await response.json()) as LinkPreviewDetails
res.url = url
return res
} catch { } catch {
return {} return {}
} }

View File

@ -115,7 +115,7 @@
{#await getJsonOrEmpty(value.file, value.name)} {#await getJsonOrEmpty(value.file, value.name)}
<Spinner size="small" /> <Spinner size="small" />
{:then linkPreviewDetails} {:then linkPreviewDetails}
<div class="flex-center icon"> <div class="flex-center icon image">
{#if linkPreviewDetails.icon !== undefined && !useDefaultIcon} {#if linkPreviewDetails.icon !== undefined && !useDefaultIcon}
<img <img
src={linkPreviewDetails.icon} src={linkPreviewDetails.icon}

View File

@ -333,7 +333,7 @@
const hrefs = refContainer.getElementsByTagName('a') const hrefs = refContainer.getElementsByTagName('a')
const newUrls: string[] = [] const newUrls: string[] = []
for (let i = 0; i < hrefs.length; i++) { for (let i = 0; i < hrefs.length; i++) {
if (hrefs[i].target !== '_blank' || !isValidUrl(hrefs[i].href)) { if (hrefs[i].target !== '_blank' || !isValidUrl(hrefs[i].href) || hrefs[i].rel === '') {
continue continue
} }
const key = getUrlKey(hrefs[i].href) const key = getUrlKey(hrefs[i].href)
@ -363,7 +363,7 @@
if (canDisplayLinkPreview(meta) && meta.url !== undefined) { if (canDisplayLinkPreview(meta) && meta.url !== undefined) {
const blob = new Blob([JSON.stringify(meta)]) const blob = new Blob([JSON.stringify(meta)])
const file = new File([blob], meta.url, { type: 'application/link-preview' }) const file = new File([blob], meta.url, { type: 'application/link-preview' })
void createAttachment(file) await createAttachment(file)
} }
} catch (err: any) { } catch (err: any) {
void setPlatformStatus(unknownError(err)) void setPlatformStatus(unknownError(err))

View File

@ -17,12 +17,14 @@
import LinkPreviewPresenter from './LinkPreviewPresenter.svelte' import LinkPreviewPresenter from './LinkPreviewPresenter.svelte'
import { type WithLookup } from '@hcengineering/core' import { type WithLookup } from '@hcengineering/core'
import { type Attachment } from '@hcengineering/attachment' import { type Attachment } from '@hcengineering/attachment'
import { Scroller } from '@hcengineering/ui'
export let attachments: WithLookup<Attachment>[] = [] export let attachments: WithLookup<Attachment>[] = []
</script> </script>
<div class="gapV-2"> <div class="gapV-2">
{#each attachments as attachment} {#each attachments as attachment}
<LinkPreviewPresenter {attachment} /> <Scroller contentDirection={'horizontal'} horizontal scrollSnap>
<LinkPreviewPresenter {attachment} />
</Scroller>
{/each} {/each}
</div> </div>

View File

@ -33,7 +33,7 @@
<div class="quote content"> <div class="quote content">
{#if canDisplay} {#if canDisplay}
<div class="gapV-2"> <div class="gapV-2">
<div class="flex gap-1"> <div class="flex-row-center gap-1">
{#if viewModel.icon !== undefined && !useDefaultIcon} {#if viewModel.icon !== undefined && !useDefaultIcon}
<img <img
src={viewModel.icon} src={viewModel.icon}
@ -81,14 +81,15 @@
max-height: 25rem; max-height: 25rem;
} }
.preview-icon { .preview-icon {
max-width: 22px; max-width: 16px;
max-height: 22px; max-height: 16px;
} }
.quote { .quote {
border-left: 0.25rem solid; border-left: 0.25rem solid;
padding-left: 15px; padding-left: 0.75rem;
} }
.content { .content {
scroll-snap-align: start;
max-width: 35rem; max-width: 35rem;
max-height: 35rem; max-height: 35rem;
} }