Skip to content
Merged
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
fix(FilePreview): use provided types of file metadata values in compo…
…nents

Signed-off-by: Maksim Sukharev <[email protected]>
  • Loading branch information
Antreesy committed Apr 8, 2024
commit d1954d266ede3e6cd5b713b97d4caa98007f2dee
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ export default {
* File size in bytes
*/
size: {
type: Number,
default: -1,
type: String,
default: '-1',
},
/**
* Download link
Expand All @@ -181,8 +181,8 @@ export default {
* File ETag
*/
permissions: {
type: Number,
default: 0,
type: String,
default: '0',
},
/**
* Whether a preview is available, string "yes" for yes
Expand All @@ -198,15 +198,15 @@ export default {
* If preview and metadata are available, return width
*/
width: {
type: Number,
type: String,
default: null,
},

/**
* If preview and metadata are available, return height
*/
height: {
type: Number,
type: String,
default: null,
},

Expand Down Expand Up @@ -407,12 +407,12 @@ export default {
}

const sizeMultiplicator = Math.min(
(heightConstraint > this.height ? 1 : (heightConstraint / this.height)),
(widthConstraint > this.width ? 1 : (widthConstraint / this.width))
(heightConstraint > parseInt(this.height, 10) ? 1 : (heightConstraint / parseInt(this.height, 10))),
(widthConstraint > parseInt(this.width, 10) ? 1 : (widthConstraint / parseInt(this.width, 10)))
)

return {
width: this.width * sizeMultiplicator + 'px',
width: parseInt(this.width, 10) * sizeMultiplicator + 'px',
aspectRatio: this.width + '/' + this.height,
}
},
Expand All @@ -426,7 +426,7 @@ export default {
return PREVIEW_TYPE.MIME_ICON
}
const maxGifSize = getCapabilities()?.spreed?.config?.previews?.['max-gif-size'] || 3145728
if (this.mimetype === 'image/gif' && this.size <= maxGifSize) {
if (this.mimetype === 'image/gif' && parseInt(this.size, 10) <= maxGifSize) {
return PREVIEW_TYPE.DIRECT
}

Expand Down