Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/DAV/GroupFoldersHome.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ public function getChildren(): array {
}

$folders = $this->folderManager->getFoldersForUser($this->user, $storageId);

// Filter out top-level folders only
$folders = array_filter($folders, function (array $folder) {
return !str_contains($folder['mount_point'], '/');
});

return array_map($this->getDirectoryForFolder(...), $folders);
}

Expand Down
17 changes: 14 additions & 3 deletions src/services/groupfolders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const data = `<?xml version="1.0"?>
<oc:size />
<nc:has-preview />
<nc:mount-point />
<nc:group-folder-id />
</d:prop>
</d:propfind>`

Expand All @@ -50,10 +51,11 @@ const resultToNode = function(node: FileStat): File | Folder {
const owner = getCurrentUser()?.uid as string
const previewUrl = generateUrl('/core/preview?fileId={fileid}&x=32&y=32&forceIcon=0', node.props)
const mountPoint = (props?.['mount-point'] || '').replace(`/files/${getCurrentUser()?.uid}`, '')
const groupFolderId = props?.['group-folder-id'] || 0

const nodeData = {
id: props?.fileid || 0,
source: generateRemoteUrl('dav' + rootPath + node.filename),
source: generateRemoteUrl('dav' + rootPath + '/' + groupFolderId),
mtime: new Date(node.lastmod),
mime: node.mime as string,
size: props?.size || 0,
Expand All @@ -66,6 +68,7 @@ const resultToNode = function(node: FileStat): File | Folder {
'mount-type': 'group',
mountPoint,
previewUrl,
displayname: node.filename.replace(/^\/+/, ''),
},
}

Expand All @@ -88,10 +91,18 @@ export const getContents = async (path = '/'): Promise<ContentsWithRoot> => {
throw new Error('Could not find root in response')
}

const contents = contentsResponse.data.filter(node => node !== root)
const contents = contentsResponse.data
.filter(node => node !== root)
.map(resultToNode)

// Filter out duplicate sources
const filteredContents = contents.filter((node, index, self) => {
const source = node.source
return self.findIndex(n => n.source === source) === index
})

return {
folder: resultToNode(root) as Folder,
contents: contents.map(resultToNode),
contents: filteredContents,
}
}
Loading