-
Notifications
You must be signed in to change notification settings - Fork 52
Fix viewing of file versions #1270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,17 +48,22 @@ export default { | |
}, | ||
|
||
isDownloadable() { | ||
if (!this.file.shareAttributes) { | ||
if (!this.file || !this.file.shareAttributes) { | ||
return true | ||
} | ||
|
||
const shareAttributes = JSON.parse(this.file.shareAttributes) | ||
const downloadPermissions = shareAttributes.find(({ scope, key }) => scope === 'permissions' && key === 'download') | ||
if (downloadPermissions) { | ||
return downloadPermissions.value | ||
try { | ||
const shareAttributes = JSON.parse(this.file.shareAttributes) | ||
const downloadPermissions = shareAttributes.find(({ scope, key }) => scope === 'permissions' && key === 'download') | ||
if (downloadPermissions) { | ||
return downloadPermissions.value | ||
} | ||
return true | ||
} catch (e) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
logger.error('Error parsing shareAttributes:', e) | ||
// If shareAttributes can not be parsed, assume the file is | ||
// downloadable to avoid locking users out of their files. | ||
return true | ||
} | ||
|
||
return true | ||
}, | ||
|
||
isRichDocumentsAvailable() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to use instead the optional chanining operator:
as it is shorter and also consistent with other usages (see, for example,
isEditable()
).The optional chaining operator should be applied too in
hideDownload
above.