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

Fix aliasing mimes #1456

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions js/viewer-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/viewer-main.js.map

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions src/views/Viewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -542,18 +542,18 @@ export default {
}
// If no provided handler, or provided handler not found: try a supported handler with mime/mime-alias
if (!handler) {
handler = this.registeredHandlers[mime] ?? this.registeredHandlers[alias]
}
handler = this.registeredHandlers[alias] ?? this.registeredHandlers[mime]

this.theme = handler.theme ?? 'dark'
// 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
// if we still 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
}
}

this.theme = handler.theme ?? 'dark'
this.handlerId = handler.id

// check if part of a group, if so retrieve full files list
Expand Down Expand Up @@ -595,7 +595,7 @@ export default {
fileInfo = this.fileList[this.currentIndex]

// show file
this.currentFile = new File(fileInfo, mime, handler.component)
this.currentFile = new File(fileInfo, mime, this.components[mime])
Copy link
Member Author

@skjnldsv skjnldsv Nov 9, 2022

Choose a reason for hiding this comment

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

If we use the original handler instead of the registered aliases, we break all aliases on file opening.

Copy link
Contributor

Choose a reason for hiding this comment

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

We could check again if the override handler is specified, if so we can use the original handler coponent?

const component = overrideHandlerId ? handler.component : this.components[mime];
this.currentFile = new File(fileInfo, mime, component)

Copy link
Member Author

Choose a reason for hiding this comment

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

No, we should be consistent on how we do things for other File creations :)

this.currentFile = new File(fileInfo, mime, this.components[mime])

this.previousFile = new File(prev, mime, this.components[mime])

this.nextFile = new File(next, mime, this.components[mime])

this.updatePreviousNext()

// if sidebar was opened before, let's update the file
Expand Down