Skip to content

Commit

Permalink
Do not load preview is version tab is not active
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <louis@chmn.me>
  • Loading branch information
artonge committed Jun 20, 2023
1 parent f6be02e commit 2cfb3c8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
14 changes: 9 additions & 5 deletions apps/files_versions/src/components/Version.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,21 @@
-->
<template>
<div>
<NcListItem class="version"
<NcListItem v-if="loadPreview"
class="version"
:title="versionLabel"
:href="downloadURL"
:force-display-actions="true"
data-files-versions-version>
<template #icon>
<img v-if="(isCurrent || version.hasPreview) && !previewError"
<div v-if="!loadPreview" class="version__image" />
<img v-else-if="isCurrent || version.hasPreview"
:src="previewURL"
alt=""
decoding="async"
fetchpriority="low"
loading="lazy"
class="version__image"
@error="previewError = true">
class="version__image">
<div v-else
class="version__image">
<ImageOffOutline :size="20" />
Expand Down Expand Up @@ -185,13 +186,16 @@ export default {
type: Boolean,
default: false,
},
loadPreview: {
type: Boolean,
default: false,
},
},
data() {
return {
showVersionLabelForm: false,
formVersionLabelValue: this.version.label,
capabilities: loadState('core', 'capabilities', { files: { version_labeling: false, version_deletion: false } }),
previewError: false,
}
},
computed: {
Expand Down
6 changes: 6 additions & 0 deletions apps/files_versions/src/views/VersionTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<ul data-files-versions-versions-list>
<Version v-for="version in orderedVersions"
:key="version.mtime"
:load-preview="isActive"
:version="version"
:file-info="fileInfo"
:is-current="version.mtime === fileInfo.mtime"
Expand Down Expand Up @@ -76,6 +77,11 @@ export default {
.map(version => version.mtime)
.reduce((a, b) => Math.min(a, b))
},

/** @return {boolean} */
isActive() {
return this.$parent.isActive
},
},
methods: {
/**
Expand Down

0 comments on commit 2cfb3c8

Please sign in to comment.