Skip to content
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

Opening an unsupported mime file freezes the UI #1579

Open
pludov opened this issue Mar 13, 2023 · 3 comments
Open

Opening an unsupported mime file freezes the UI #1579

pludov opened this issue Mar 13, 2023 · 3 comments
Labels
0. Needs triage Pending approval or rejection. This issue is pending approval. bug Something isn't working good first issue Good for newcomers

Comments

@pludov
Copy link

pludov commented Mar 13, 2023

Describe the bug

Opening an unsupported mime file from the file view freeze on the wait icon, with no error message displayed to the user

To Reproduce

Run the following in console while browsing files:

OCA.Viewer.open({path:'/path/to/unuspported-mime.type'})

The console reports:

Viewer.vue:450 TypeError: Cannot read properties of undefined (reading 'theme')
    at Viewer.vue:399:1
    at u (runtime.js:63:40)
    at Generator._invoke (runtime.js:294:22)
    at Generator.next (runtime.js:119:21)
    at Vm (Download.vue?b226:19:33)
    at i (Download.vue?b226:19:33)

Probable fix

Seems that in Viewer.vue - https://github.com/nextcloud/viewer/blame/22e47429df029eeb2f36e2361f49e59768dec725/src/views/Viewer.vue#L559 , the use of the handler variable should be swapped with its verification:

			this.theme = handler.theme ?? 'dark'               // Moving that after the if to bring back error message 
			// if we don't have a handler for this mime, abort
			if (!handler) {
				logger.error('The following file could not be displayed', { fileInfo })
				showError(t('viewer', 'There is no plugin available to display this file type'))
				this.close()
				return
			}
@pludov pludov added 0. Needs triage Pending approval or rejection. This issue is pending approval. bug Something isn't working labels Mar 13, 2023
@skjnldsv skjnldsv added the good first issue Good for newcomers label Mar 16, 2023
@pushyajn01

This comment was marked as off-topic.

@joshtrichards
Copy link
Member

@Pushyajain There's no need to get "assigned" it - if you have a proposed implementation submit it as PR from your own fork of the repository.

@eldertek
Copy link

Hello, having the same issue.
Opening from my app using this code. With a filePath pointing to a file with a mimetype not supported.
OCA.Viewer.open({path: filePath,});

Give me this error in console.
Viewer.vue:639 Could not open file /LICENSE.md TypeError: Cannot read properties of undefined (reading 'theme') at o.openFileInfo (Viewer.vue:675:1) at o.openFile (Viewer.vue:632:1)

How can I deal with that from my app ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. Needs triage Pending approval or rejection. This issue is pending approval. bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants