Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(files_versions): Rely on server mime fallback icons
Signed-off-by: provokateurin <[email protected]>
  • Loading branch information
provokateurin committed Mar 28, 2025
commit e05838e259d0b63b148a71a961c84219033728d5
2 changes: 1 addition & 1 deletion apps/files_versions/src/components/Version.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,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"
Expand Down
6 changes: 2 additions & 4 deletions apps/files_versions/src/utils/versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
})
Expand All @@ -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),
Expand Down
5 changes: 2 additions & 3 deletions apps/files_versions/src/views/VersionTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,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,
}))

Expand All @@ -291,7 +290,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))
},
Expand Down