diff --git a/src/components/FileLegacy.vue b/src/components/FileLegacy.vue index 16ea8aa2d..d33b64edd 100644 --- a/src/components/FileLegacy.vue +++ b/src/components/FileLegacy.vue @@ -105,7 +105,7 @@ export default { methods: { openViewer() { OCA.Viewer.open({ - path: this.item.injected.filename, + fileInfo: this.item.injected, list: this.item.injected.list, loadMore: this.item.injected.loadMore ? async () => await this.item.injected.loadMore(true) : () => [], canLoop: this.item.injected.canLoop, diff --git a/src/services/AlbumContent.js b/src/services/AlbumContent.js index f6fea719f..92a2ec3ca 100644 --- a/src/services/AlbumContent.js +++ b/src/services/AlbumContent.js @@ -24,6 +24,7 @@ import axios from '@nextcloud/axios' import { generateUrl } from '@nextcloud/router' import { genFileInfo, encodeFilePath } from '../utils/fileUtils.js' import allowedMimes from './AllowedMimes.js' +import { getCurrentUser } from '@nextcloud/auth' /** * List files from a folder and filter out unwanted mimes @@ -34,11 +35,16 @@ import allowedMimes from './AllowedMimes.js' * @return {Promise} the file list */ export default async function(path = '/', options = {}) { - const prefixPath = generateUrl(`/apps/photos/api/v1/${options.shared ? 'shared' : 'albums'}`) + const endpoint = generateUrl(`/apps/photos/api/v1/${options.shared ? 'shared' : 'albums'}`) + const prefix = `/files/${getCurrentUser()?.uid}` + + path = path.replace(new RegExp(`^${prefix}`), '') // fetch listing - const response = await axios.get(prefixPath + encodeFilePath(path), options) - const list = response.data.map(data => genFileInfo(data)) + const response = await axios.get(endpoint + encodeFilePath(path), options) + const list = response.data + .map(data => ({ ...data, filename: `${prefix}${data.filename}` })) + .map(data => genFileInfo(data)) // filter all the files and folders let folder = {} @@ -47,7 +53,7 @@ export default async function(path = '/', options = {}) { for (const entry of list) { // is this the current provided path ? - if (entry.filename === path) { + if (entry.filename === `${prefix}${path}`) { folder = entry } else if (entry.type !== 'file') { folders.push(entry)