Disable video preload in inbox left panel (#4902)

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
Kristina 2024-03-08 11:24:59 +04:00 committed by GitHub
parent ba393d9e51
commit 0483e2ac0d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 16 additions and 5 deletions

View File

@ -37,6 +37,7 @@
export let withShowMore: boolean = true export let withShowMore: boolean = true
export let attachmentImageSize: 'x-large' | undefined = undefined export let attachmentImageSize: 'x-large' | undefined = undefined
export let showLinksPreview = true export let showLinksPreview = true
export let videoPreload = true
export let onClick: (() => void) | undefined = undefined export let onClick: (() => void) | undefined = undefined
export let onReply: (() => void) | undefined = undefined export let onReply: (() => void) | undefined = undefined
@ -68,6 +69,7 @@
withShowMore, withShowMore,
attachmentImageSize, attachmentImageSize,
showLinksPreview, showLinksPreview,
videoPreload,
onClick, onClick,
onReply onReply
}} }}

View File

@ -24,6 +24,7 @@
export let value: Doc & { attachments?: number } export let value: Doc & { attachments?: number }
export let attachments: Attachment[] | undefined = undefined export let attachments: Attachment[] | undefined = undefined
export let imageSize: AttachmentImageSize = 'auto' export let imageSize: AttachmentImageSize = 'auto'
export let videoPreload = true
const query = createQuery() const query = createQuery()
const savedAttachmentsQuery = createQuery() const savedAttachmentsQuery = createQuery()
@ -59,4 +60,4 @@
}) })
</script> </script>
<AttachmentList attachments={resAttachments} {savedAttachmentsIds} {imageSize} /> <AttachmentList attachments={resAttachments} {savedAttachmentsIds} {imageSize} {videoPreload} />

View File

@ -23,6 +23,7 @@
export let attachments: Attachment[] = [] export let attachments: Attachment[] = []
export let savedAttachmentsIds: Ref<Attachment>[] = [] export let savedAttachmentsIds: Ref<Attachment>[] = []
export let imageSize: AttachmentImageSize | undefined = undefined export let imageSize: AttachmentImageSize | undefined = undefined
export let videoPreload = true
</script> </script>
{#if attachments.length} {#if attachments.length}
@ -32,6 +33,7 @@
value={attachment} value={attachment}
isSaved={savedAttachmentsIds?.includes(attachment._id) ?? false} isSaved={savedAttachmentsIds?.includes(attachment._id) ?? false}
{imageSize} {imageSize}
{videoPreload}
/> />
{/each} {/each}
</Scroller> </Scroller>

View File

@ -33,6 +33,7 @@
export let listProvider: ListSelectionProvider | undefined = undefined export let listProvider: ListSelectionProvider | undefined = undefined
export let imageSize: AttachmentImageSize = 'auto' export let imageSize: AttachmentImageSize = 'auto'
export let removable: boolean = false export let removable: boolean = false
export let videoPreload = true
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
@ -69,7 +70,7 @@
</div> </div>
{:else if type === 'video'} {:else if type === 'video'}
<div class="content buttonContainer flex-center"> <div class="content buttonContainer flex-center">
<AttachmentVideoPreview {value} /> <AttachmentVideoPreview {value} preload={videoPreload} />
<div class="actions conner"> <div class="actions conner">
<AttachmentActions attachment={value} {isSaved} {removable} /> <AttachmentActions attachment={value} {isSaved} {removable} />
</div> </div>

View File

@ -19,6 +19,7 @@
import AttachmentPresenter from './AttachmentPresenter.svelte' import AttachmentPresenter from './AttachmentPresenter.svelte'
export let value: Attachment export let value: Attachment
export let preload = true
const maxSizeRem = 20 const maxSizeRem = 20
const baseSizeRem = 12 const baseSizeRem = 12
@ -55,7 +56,7 @@
} }
</script> </script>
<video controls width={dimensions.width} height={dimensions.height}> <video controls width={dimensions.width} height={dimensions.height} preload={preload ? 'auto' : 'none'}>
<source src={getFileUrl(value.file, 'full', value.name)} /> <source src={getFileUrl(value.file, 'full', value.name)} />
<track kind="captions" label={value.name} /> <track kind="captions" label={value.name} />
<div class="container"> <div class="container">

View File

@ -48,6 +48,7 @@
export let withShowMore: boolean = true export let withShowMore: boolean = true
export let attachmentImageSize: AttachmentImageSize = 'auto' export let attachmentImageSize: AttachmentImageSize = 'auto'
export let showLinksPreview = true export let showLinksPreview = true
export let videoPreload = true
export let onClick: (() => void) | undefined = undefined export let onClick: (() => void) | undefined = undefined
export let onReply: (() => void) | undefined = undefined export let onReply: (() => void) | undefined = undefined
@ -193,7 +194,7 @@
<ShowMore> <ShowMore>
<div class="clear-mins"> <div class="clear-mins">
<MessageViewer message={value.message} /> <MessageViewer message={value.message} />
<AttachmentDocList {value} {attachments} imageSize={attachmentImageSize} /> <AttachmentDocList {value} {attachments} imageSize={attachmentImageSize} {videoPreload} />
{#each links as link} {#each links as link}
<LinkPresenter {link} /> <LinkPresenter {link} />
{/each} {/each}
@ -202,7 +203,7 @@
{:else} {:else}
<div class="clear-mins"> <div class="clear-mins">
<MessageViewer message={value.message} /> <MessageViewer message={value.message} />
<AttachmentDocList {value} {attachments} imageSize={attachmentImageSize} /> <AttachmentDocList {value} {attachments} imageSize={attachmentImageSize} {videoPreload} />
{#each links as link} {#each links as link}
<LinkPresenter {link} /> <LinkPresenter {link} />
{/each} {/each}

View File

@ -40,6 +40,7 @@
export let withShowMore: boolean = true export let withShowMore: boolean = true
export let hoverStyles: 'borderedHover' | 'filledHover' = 'borderedHover' export let hoverStyles: 'borderedHover' | 'filledHover' = 'borderedHover'
export let attachmentImageSize: AttachmentImageSize = 'x-large' export let attachmentImageSize: AttachmentImageSize = 'x-large'
export let videoPreload = true
export let onClick: (() => void) | undefined = undefined export let onClick: (() => void) | undefined = undefined
export let onReply: (() => void) | undefined = undefined export let onReply: (() => void) | undefined = undefined
@ -76,6 +77,7 @@
{hoverStyles} {hoverStyles}
{withShowMore} {withShowMore}
{attachmentImageSize} {attachmentImageSize}
{videoPreload}
showLinksPreview={false} showLinksPreview={false}
{onClick} {onClick}
{onReply} {onReply}

View File

@ -141,6 +141,7 @@
{actions} {actions}
hoverable={false} hoverable={false}
{withFlatActions} {withFlatActions}
videoPreload={false}
onReply={() => { onReply={() => {
handleReply(displayMessage) handleReply(displayMessage)
}} }}