Skip to content

Conversation

lobermann
Copy link

Fixes the issue reported at #1269

When trying to look at older versions of a pdf file, there was always an error as this.file was undefined.
By adding a check for this to isDownloadable() this starts to work without an issue

Fixes the issue reported at nextcloud#1269
When trying to look at older versions of a pdf file, there was always an error as this.file was undefined.
By adding a check for this to isDownloadable() this starts to work without an issue

Signed-off-by: Lukas Obermann <[email protected]>
@szaimen
Copy link
Collaborator

szaimen commented Sep 19, 2025

/backport to stable32

@szaimen
Copy link
Collaborator

szaimen commented Sep 19, 2025

/backport to stable31

@lobermann
Copy link
Author

I found an additional issue that I fixed in the second commit.
We have a file where, when selecting the first version, JSON.prase throws an exception, which then causes the pdf viewer to stay stuck on the loading indicator.

… current version in the version history

Signed-off-by: Lukas Obermann <[email protected]>
Copy link

github-actions bot commented Oct 2, 2025

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

Copy link
Member

@danxuliu danxuliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the long delay, and thanks a lot for your contribution!

While reviewing it I noticed some further errors in the console when viewing file versions. Those errors are not caused by the changes here, but seem to be "unveiled" by them. I will investigate them further and see if I can fix them here too, or if they should be fixed later in another pull request.

Independently of that, I left some comments that it would be great if you could address. But if you prefer me to change that please let me know, that would be totally fine too! Thanks :-)

isDownloadable() {
if (!this.file.shareAttributes) {
if (!this.file || !this.file.shareAttributes) {
Copy link
Member

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:

if (!this.file?.shareAttributes) {

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.

return downloadPermissions.value
}
return true
} catch (e) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The try { } catch should enclose only the const shareAttributes = JSON.parse(this.file.shareAttributes) statement, as it is guarding against a parsing error, and the rest of statements should be safe to execute (at least if the function returns early in the catch like it does now).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants