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
1 change: 0 additions & 1 deletion src/models/videos.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export default {
'video/ogg',
'video/webm',
'video/mp4',
'video/x-matroska',
'video/x-m4v',
'video/x-flv',
'video/quicktime'
Expand Down
81 changes: 55 additions & 26 deletions src/views/Viewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ export default {

const group = this.mimeGroups[mime]
const mimes = this.mimeGroups[group]
? this.mimeGroups[group]
: [mime]

// retrieve, sort and store file List
const fileList = await FileList(OC.getCurrentUser().uid, fileInfo.dir, mimes)
Expand All @@ -206,9 +208,13 @@ export default {
// store current position
this.currentIndex = this.fileList.findIndex(file => file.name === fileName)

// get saved fileInfo
fileInfo = this.fileList[this.currentIndex]

// override mimetype if existing alias
mime = this.getAliasIfAny(mime)

if (this.components[mime]) {
mime = this.getAliasIfAny(mime)
this.currentFile = {
relativePath,
path,
Expand All @@ -219,9 +225,10 @@ export default {
modal: this.components[mime],
loaded: false
}
this.updatePreviousNext()
} else {
console.error(`The following file could not be displayed because to view matches its mime type`, fileName, fileInfo)
Copy link
Member

Choose a reason for hiding this comment

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

I feel this could be easier written?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is meant to be a dev debug. Since no regular user would open the console I guess 🤔
But I've always been terrible at writing error messages, so feel free to suggest a simpler one 😁

Copy link
Member

Choose a reason for hiding this comment

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

@skjnldsv Hey no worries. I thought it was just unclear what it said. I am actually struggling understanding: "because to view matches". What about this: "The following file could not be displayed due to it's mime type"?

}

this.updatePreviousNext()
},

/**
Expand Down Expand Up @@ -326,29 +333,29 @@ export default {

// checking valid handler id
if (!handler.id || handler.id.trim() === '' || typeof handler.id !== 'string') {
console.error(`The following handler doesn't have proper id`, handler)
console.error(`The following handler doesn't have a valid id`, handler)
return
}

// checking valid handler mime data
if (!handler.mimes || !Array.isArray(handler.mimes)) {
console.error(`The following handler doesn't have proper mime data`, handler)
// checking if no valid mimes data and no mimes Aliases
if (!(handler.mimes && Array.isArray(handler.mimes)) && !handler.mimesAliases) {
console.error(`The following handler doesn't have a valid mime array`, handler)
return
}

// checking valid handler component data
if (!handler.component || typeof handler.component !== 'object') {
console.error(`The following handler doesn't have proper component`, handler)
if (handler.mimesAliases && typeof handler.mimesAliases !== 'object') {
console.error(`The following handler doesn't have a valid mimesAliases object`, handler)
return

}

handler.mimes.forEach(mime => {
// checking valid mime
if (this.components[mime]) {
console.error(`The following mime is already registered`, mime, handler)
return
}
// checking valid handler component data AND no alias (we can register alias without component)
if ((!handler.component || typeof handler.component !== 'object') && !handler.mimesAliases) {
console.error(`The following handler doesn't have a valid component`, handler)
return
}

const register = ({ mime, handler }) => {
// unregistered handler, let's go!
OCA.Files.fileActions.registerAction({
name: 'view',
Expand All @@ -369,19 +376,41 @@ export default {
this.mimeGroups[handler.group].push(mime)
}

if (handler.mimesAliases) {
Object.keys(handler.mimesAliases).forEach(mime => {
this.mimesAliases[mime] = handler.mimesAliases[mime]
})
}

// set the handler as registered
this.registeredHandlers.push(handler.id)
}

// register mime's component
this.components[mime] = handler.component
Vue.component(handler.component.name, handler.component)
})
// parsing mimes registration
if (handler.mimes) {
handler.mimes.forEach(mime => {
// checking valid mime
if (this.components[mime]) {
console.error(`The following mime is already registered`, mime, handler)
return
}

register({ mime, handler })

// register mime's component
this.components[mime] = handler.component
Vue.component(handler.component.name, handler.component)
})
}

// parsing aliases registration
if (handler.mimesAliases) {
Object.keys(handler.mimesAliases).forEach(mime => {
// checking valid mime
if (this.components[mime]) {
console.error(`The following mime is already registered`, mime, handler)
return
}

register({ mime, handler })

this.mimesAliases[mime] = handler.mimesAliases[mime]
})
}
},

getPath(fileInfo) {
Expand Down