Skip to content

Opening an unsupported mime file freezes the UI #1579

Open
@pludov

Description

@pludov

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
			}

Metadata

Metadata

Assignees

No one assigned

    Labels

    0. Needs triagePending approval or rejection. This issue is pending approval.bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions