Skip to content
Merged
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: 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
36 changes: 15 additions & 21 deletions src/views/Viewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
</template>

<script>
import Mime from 'mime-types'
import Vue from 'vue'

import Modal from 'nextcloud-vue/dist/Components/Modal'
Expand Down Expand Up @@ -129,15 +128,15 @@ export default {

computed: {
hasPrevious() {
return this.currentIndex > 0
return this.fileList.length > 1
},
hasNext() {
return this.currentIndex < this.fileList.length - 1
return this.fileList.length > 1
},
currentFileName() {
if (this.currentFile && this.currentFile.path) {
const path = this.currentFile.path.split('/')
return path[path.length - 1]
return decodeURI(path[path.length - 1])
}
return ''
},
Expand Down Expand Up @@ -193,7 +192,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 +222,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 +247,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 +265,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 +359,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 All @@ -391,7 +377,11 @@ export default {
previous() {
this.loading = true
this.failed = false

this.currentIndex--
if (this.currentIndex < 0) {
this.currentIndex = this.fileList.length - 1
}

this.openFileFromList(this.fileList[this.currentIndex])
},
Expand All @@ -402,7 +392,11 @@ export default {
next() {
this.loading = true
this.failed = false

this.currentIndex++
if (this.currentIndex > this.fileList.length - 1) {
this.currentIndex = 0
}

this.openFileFromList(this.fileList[this.currentIndex])
},
Expand Down