Skip to content

Commit

Permalink
Use full filenames in folder view
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <louis@chmn.me>
  • Loading branch information
artonge committed Feb 23, 2023
1 parent 4b471b5 commit 9a3f586
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 14 deletions.
4 changes: 2 additions & 2 deletions js/photos-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-main.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/photos-public.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-public.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/photos-src_views_Folders_vue.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-src_views_Folders_vue.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/components/FileLegacy.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 10 additions & 4 deletions src/services/AlbumContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -34,11 +35,16 @@ import allowedMimes from './AllowedMimes.js'
* @return {Promise<object[]>} 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 = {}
Expand All @@ -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)
Expand Down

0 comments on commit 9a3f586

Please sign in to comment.