diff options
author | Louis Chemineau <louis@chmn.me> | 2023-06-28 16:44:12 +0200 |
---|---|---|
committer | Louis Chemineau <louis@chmn.me> | 2023-06-28 17:00:23 +0200 |
commit | 6eb93c652a133dcee0f95ab3be7900a6e40497c8 (patch) | |
tree | 43de701474ebb94d1285c3da28dc7c95d447515e /apps/files_versions | |
parent | 36c3846475cf132caca656c11a954343495dccbe (diff) | |
download | nextcloud-server-6eb93c652a133dcee0f95ab3be7900a6e40497c8.tar.gz nextcloud-server-6eb93c652a133dcee0f95ab3be7900a6e40497c8.zip |
Do not load preview if version tab is not active
Signed-off-by: Louis Chemineau <louis@chmn.me>
Diffstat (limited to 'apps/files_versions')
-rw-r--r-- | apps/files_versions/src/components/Version.vue | 11 | ||||
-rw-r--r-- | apps/files_versions/src/files_versions_tab.js | 3 | ||||
-rw-r--r-- | apps/files_versions/src/views/VersionTab.vue | 9 |
3 files changed, 20 insertions, 3 deletions
diff --git a/apps/files_versions/src/components/Version.vue b/apps/files_versions/src/components/Version.vue index 096c31990f0..ec03a1c2b31 100644 --- a/apps/files_versions/src/components/Version.vue +++ b/apps/files_versions/src/components/Version.vue @@ -23,14 +23,15 @@ :force-display-actions="true" data-files-versions-version> <template #icon> - <img v-if="(isCurrent || version.hasPreview) && !previewError" + <div v-if="!(loadPreview || previewLoaded)" 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"> + @load="previewLoaded = true"> <div v-else class="version__image"> <ImageOffOutline :size="20" /> @@ -185,13 +186,17 @@ export default { type: Boolean, default: false, }, + loadPreview: { + type: Boolean, + default: false, + }, }, data() { return { + previewLoaded: false, showVersionLabelForm: false, formVersionLabelValue: this.version.label, capabilities: loadState('core', 'capabilities', { files: { version_labeling: false, version_deletion: false } }), - previewError: false, } }, computed: { diff --git a/apps/files_versions/src/files_versions_tab.js b/apps/files_versions/src/files_versions_tab.js index 225add57252..8b816746401 100644 --- a/apps/files_versions/src/files_versions_tab.js +++ b/apps/files_versions/src/files_versions_tab.js @@ -59,6 +59,9 @@ window.addEventListener('DOMContentLoaded', function() { update(fileInfo) { TabInstance.update(fileInfo) }, + setIsActive(isActive) { + TabInstance.setIsActive(isActive) + }, destroy() { TabInstance.$destroy() TabInstance = null diff --git a/apps/files_versions/src/views/VersionTab.vue b/apps/files_versions/src/views/VersionTab.vue index 04b6ecf1add..6d3b07c2f88 100644 --- a/apps/files_versions/src/views/VersionTab.vue +++ b/apps/files_versions/src/views/VersionTab.vue @@ -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" @@ -42,6 +43,7 @@ export default { data() { return { fileInfo: null, + isActive: false, /** @type {import('../utils/versions.js').Version[]} */ versions: [], loading: false, @@ -90,6 +92,13 @@ export default { }, /** + * @param {boolean} isActive whether the tab is active + */ + async setIsActive(isActive) { + this.isActive = isActive + }, + + /** * Get the existing versions infos */ async fetchVersions() { |