Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Use file app mime data
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
  • Loading branch information
skjnldsv committed Mar 14, 2019
commit 0fc61a50e0460879888001d594cc577cea2de9fe
4 changes: 3 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"dependencies": {
"axios": "^0.18.0",
"debounce": "^1.2.0",
"mime-types": "^2.1.22",
"nextcloud-server": "^0.15.9",
"nextcloud-vue": "^0.9.1",
"vue": "^2.6.8",
Expand Down
21 changes: 4 additions & 17 deletions src/views/Viewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export default {
const relativePath = `${fileInfo.dir !== '/' ? fileInfo.dir : ''}/${fileName}`
const path = `${this.root}${relativePath}`

const mime = this.getMime(path)
const mime = fileInfo.$file.data('mime')

const group = this.mimeGroups[mime]
const mimes = this.mimeGroups[group]
Expand Down Expand Up @@ -223,7 +223,7 @@ export default {
*/
openFileFromList(fileInfo) {
const path = fileInfo.href
const mime = this.getMime(path)
const mime = fileInfo.mimetype
const modal = this.components[mime]

if (modal) {
Expand All @@ -248,7 +248,7 @@ export default {

if (prev) {
const path = prev.href
const mime = this.getMime(path)
const mime = prev.mimetype
const modal = this.components[mime]

if (modal) {
Expand All @@ -266,7 +266,7 @@ export default {

if (next) {
const path = next.href
const mime = this.getMime(path)
const mime = next.mimetype
const modal = this.components[mime]

if (modal) {
Expand Down Expand Up @@ -360,19 +360,6 @@ export default {
})
},

/**
* Extract mime from file path or use existing alias
*
* @param {String} path the file path
* @returns {String} the mime type
*/
getMime(path) {
const mime = Mime.lookup(path)
return this.mimesAliases[mime]
? this.mimesAliases[mime]
: mime
},

/**
* Close the viewer
*/
Expand Down