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 <[email protected]>
  • Loading branch information
vanpertsch authored and max-nextcloud committed Aug 26, 2022
1 parent f5345a0 commit 4b1596e
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 @@ -141,7 +141,7 @@ import NcModal from '@nextcloud/vue/dist/Components/NcModal.js'
import isFullscreen from '@nextcloud/vue/dist/Mixins/isFullscreen.js'
import isMobile from '@nextcloud/vue/dist/Mixins/isMobile'

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 @@ -508,7 +508,7 @@ export default {

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

0 comments on commit 4b1596e

Please sign in to comment.