diff options
author | Louis Chemineau <louis@chmn.me> | 2023-06-19 17:51:53 +0200 |
---|---|---|
committer | Louis Chemineau <louis@chmn.me> | 2023-06-28 16:46:48 +0200 |
commit | 36c3846475cf132caca656c11a954343495dccbe (patch) | |
tree | a61ebc97f3e0263efb584a34db51a40e1e12e90b /apps/files_versions/src | |
parent | 0d9abed75454d022190024f5a5951cd1aed315b8 (diff) | |
download | nextcloud-server-36c3846475cf132caca656c11a954343495dccbe.tar.gz nextcloud-server-36c3846475cf132caca656c11a954343495dccbe.zip |
Provide hasPreview in files_versions DAV API
This allow to no request non existing previews
I also set some properties to the img element to reduce preview loading to what the browser think is necessary
Signed-off-by: Louis Chemineau <louis@chmn.me>
Diffstat (limited to 'apps/files_versions/src')
-rw-r--r-- | apps/files_versions/src/components/Version.vue | 5 | ||||
-rw-r--r-- | apps/files_versions/src/utils/davRequest.js | 1 | ||||
-rw-r--r-- | apps/files_versions/src/utils/versions.js | 2 |
3 files changed, 7 insertions, 1 deletions
diff --git a/apps/files_versions/src/components/Version.vue b/apps/files_versions/src/components/Version.vue index def5abbcf48..096c31990f0 100644 --- a/apps/files_versions/src/components/Version.vue +++ b/apps/files_versions/src/components/Version.vue @@ -23,9 +23,12 @@ :force-display-actions="true" data-files-versions-version> <template #icon> - <img v-if="!previewError" + <img v-if="(isCurrent || version.hasPreview) && !previewError" :src="previewURL" alt="" + decoding="async" + fetchpriority="low" + loading="lazy" class="version__image" @error="previewError = true"> <div v-else diff --git a/apps/files_versions/src/utils/davRequest.js b/apps/files_versions/src/utils/davRequest.js index fb2126d98bf..fec64caa2d5 100644 --- a/apps/files_versions/src/utils/davRequest.js +++ b/apps/files_versions/src/utils/davRequest.js @@ -30,5 +30,6 @@ export default `<?xml version="1.0"?> <d:getcontenttype /> <d:getlastmodified /> <nc:version-label /> + <nc:has-preview /> </d:prop> </d:propfind>` diff --git a/apps/files_versions/src/utils/versions.js b/apps/files_versions/src/utils/versions.js index 1a5dde10824..71593dd0ce8 100644 --- a/apps/files_versions/src/utils/versions.js +++ b/apps/files_versions/src/utils/versions.js @@ -36,6 +36,7 @@ import moment from '@nextcloud/moment' * @property {string} size - Human readable size * @property {string} type - 'file' * @property {number} mtime - Version creation date as a timestamp + * @property {boolean} hasPreview - Whether the version has a preview * @property {string} preview - Preview URL of the version * @property {string} url - Download URL of the version * @property {string|null} fileVersion - The version id, null for the current version @@ -98,6 +99,7 @@ function formatVersion(version, fileInfo) { size: version.size, type: version.type, mtime: moment(version.lastmod).unix() * 1000, + hasPreview: version.props['has-preview'] === 1, preview: generateUrl('/apps/files_versions/preview?file={file}&version={fileVersion}', { file: joinPaths(fileInfo.path, fileInfo.name), fileVersion: version.basename, |