mirror of
https://github.com/nextcloud/server.git
synced 2026-02-14 16:25:29 -05:00
fix(files_versions): Rely on server mime fallback icons
Signed-off-by: provokateurin <kate@provokateurin.de>
This commit is contained in:
parent
d15ea1f17e
commit
dab670f289
3 changed files with 5 additions and 8 deletions
|
|
@ -11,7 +11,7 @@
|
|||
<!-- Icon -->
|
||||
<template #icon>
|
||||
<div v-if="!(loadPreview || previewLoaded)" class="version__image" />
|
||||
<img v-else-if="(isCurrent || version.hasPreview) && !previewErrored"
|
||||
<img v-else-if="version.previewUrl && !previewErrored"
|
||||
:src="version.previewUrl"
|
||||
alt=""
|
||||
decoding="async"
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ export interface Version {
|
|||
type: string, // 'file'
|
||||
mtime: number, // Version creation date as a timestamp
|
||||
permissions: string, // Only readable: 'R'
|
||||
hasPreview: boolean, // Whether the version has a preview
|
||||
previewUrl: string, // Preview URL of the version
|
||||
url: string, // Download URL of the version
|
||||
source: string, // The WebDAV endpoint of the ressource
|
||||
|
|
@ -78,12 +77,12 @@ function formatVersion(version: any, fileInfo: any): Version {
|
|||
let previewUrl = ''
|
||||
|
||||
if (mtime === fileInfo.mtime) { // Version is the current one
|
||||
previewUrl = generateUrl('/core/preview?fileId={fileId}&c={fileEtag}&x=250&y=250&forceIcon=0&a=0', {
|
||||
previewUrl = generateUrl('/core/preview?fileId={fileId}&c={fileEtag}&x=250&y=250&forceIcon=0&a=0&forceIcon=1&mimeFallback=1', {
|
||||
fileId: fileInfo.id,
|
||||
fileEtag: fileInfo.etag,
|
||||
})
|
||||
} else {
|
||||
previewUrl = generateUrl('/apps/files_versions/preview?file={file}&version={fileVersion}', {
|
||||
previewUrl = generateUrl('/apps/files_versions/preview?file={file}&version={fileVersion}&mimeFallback=1', {
|
||||
file: joinPaths(fileInfo.path, fileInfo.name),
|
||||
fileVersion: version.basename,
|
||||
})
|
||||
|
|
@ -102,7 +101,6 @@ function formatVersion(version: any, fileInfo: any): Version {
|
|||
type: version.type,
|
||||
mtime,
|
||||
permissions: 'R',
|
||||
hasPreview: version.props['has-preview'] === 1,
|
||||
previewUrl,
|
||||
url: joinPaths('/remote.php/dav', version.filename),
|
||||
source: generateRemoteUrl('dav') + encodePath(version.filename),
|
||||
|
|
|
|||
|
|
@ -273,13 +273,12 @@ export default {
|
|||
return
|
||||
}
|
||||
|
||||
// Versions previews are too small for our use case, so we override hasPreview and previewUrl
|
||||
// Versions previews are too small for our use case, so we override previewUrl
|
||||
// which makes the viewer render the original file.
|
||||
// We also point to the original filename if the version is the current one.
|
||||
const versions = this.versions.map(version => ({
|
||||
...version,
|
||||
filename: version.mtime === this.fileInfo.mtime ? path.join('files', getCurrentUser()?.uid ?? '', this.fileInfo.path, this.fileInfo.name) : version.filename,
|
||||
hasPreview: false,
|
||||
previewUrl: undefined,
|
||||
}))
|
||||
|
||||
|
|
@ -290,7 +289,7 @@ export default {
|
|||
},
|
||||
|
||||
compareVersion({ version }) {
|
||||
const versions = this.versions.map(version => ({ ...version, hasPreview: false, previewUrl: undefined }))
|
||||
const versions = this.versions.map(version => ({ ...version, previewUrl: undefined }))
|
||||
|
||||
OCA.Viewer.compare(this.viewerFileInfo, versions.find(v => v.source === version.source))
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue