diff --git a/src/utils/fileUtils.js b/src/utils/fileUtils.js index 74ac05730..7016eadd4 100644 --- a/src/utils/fileUtils.js +++ b/src/utils/fileUtils.js @@ -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 * @@ -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 } diff --git a/src/views/Viewer.vue b/src/views/Viewer.vue index a726d8709..9fdf962d3 100644 --- a/src/views/Viewer.vue +++ b/src/views/Viewer.vue @@ -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' @@ -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]