Skip to content

Commit bac449e

Browse files
provokateurinbackportbot[bot]
authored andcommitted
fix(GroupFoldersHome): Show all leaf groupfolders
Signed-off-by: provokateurin <kate@provokateurin.de>
1 parent dba28c6 commit bac449e

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

β€Žlib/DAV/GroupFoldersHome.phpβ€Ž

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use OC\Files\Filesystem;
1212
use OCA\GroupFolders\Folder\FolderDefinition;
13+
use OCA\GroupFolders\Folder\FolderDefinitionWithPermissions;
1314
use OCA\GroupFolders\Folder\FolderManager;
1415
use OCP\Files\IRootFolder;
1516
use OCP\IUser;
@@ -103,10 +104,18 @@ public function getChildren(): array {
103104

104105
$folders = $this->folderManager->getFoldersForUser($this->user);
105106

106-
// Filter out non top-level folders
107-
$folders = array_filter($folders, fn (FolderDefinition $folder): bool => !str_contains($folder->mountPoint, '/'));
107+
usort($folders, static fn (FolderDefinitionWithPermissions $a, FolderDefinitionWithPermissions $b): int => $a->mountPoint <=> $b->mountPoint);
108108

109-
return array_map($this->getDirectoryForFolder(...), $folders);
109+
$current = '';
110+
$leafFolders = [];
111+
foreach ($folders as $folder) {
112+
if (!str_starts_with($folder->mountPoint, $current . '/')) {
113+
$leafFolders[] = $folder;
114+
$current = $folder->mountPoint;
115+
}
116+
}
117+
118+
return array_map($this->getDirectoryForFolder(...), $leafFolders);
110119
}
111120

112121
#[\Override]

0 commit comments

Comments
Β (0)