Skip to content

Commit

Permalink
enable opening a single shared file
Browse files Browse the repository at this point in the history
Signed-off-by: Vanessa Pertsch <vanessa.pertsch@posteo.de>
  • Loading branch information
vanpertsch committed May 11, 2022
1 parent f828cf5 commit 7f0527c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 13 additions & 1 deletion src/utils/fileUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ const extractFilePaths = function(path) {
return [dirPath, fileName]
}

/**
* A single shared file can be opend with path: '/'.
* In this case there is no parent folder to find sibling files in.
*
* @param {string} path the full path
* @return {boolean}
*/
const isSingleSharedFile = function(path) {

return path === '/'
}

/**
* Sorting comparison function
*
Expand Down Expand Up @@ -141,4 +153,4 @@ const getDavPath = function({ filename, basename }) {
return getRootPath() + encodeFilePath(filename)
}

export { encodeFilePath, extractFilePaths, sortCompare, genFileInfo, getDavPath }
export { encodeFilePath, extractFilePaths, isSingleSharedFile, sortCompare, genFileInfo, getDavPath }
4 changes: 2 additions & 2 deletions src/views/Viewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ import ActionLink from '@nextcloud/vue/dist/Components/ActionLink.js'
import isFullscreen from '@nextcloud/vue/dist/Mixins/isFullscreen.js'
import Modal from '@nextcloud/vue/dist/Components/Modal.js'

import { extractFilePaths, sortCompare } from '../utils/fileUtils.js'
import { extractFilePaths, isSingleSharedFile, sortCompare } from '../utils/fileUtils.js'
import { getRootPath } from '../utils/davUtils.js'
import canDownload from '../utils/canDownload.js'
import cancelableRequest from '../utils/CancelableRequest.js'
Expand Down Expand Up @@ -402,7 +402,7 @@ export default {

// store current position
this.currentIndex = this.fileList.findIndex(file => file.basename === fileName)
} else if (group) {
} else if (group && !isSingleSharedFile(path)) {
const mimes = this.mimeGroups[group]
? this.mimeGroups[group]
: [mime]
Expand Down

0 comments on commit 7f0527c

Please sign in to comment.