File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change 1010
1111use OC \Files \Filesystem ;
1212use OCA \GroupFolders \Folder \FolderDefinition ;
13+ use OCA \GroupFolders \Folder \FolderDefinitionWithPermissions ;
1314use OCA \GroupFolders \Folder \FolderManager ;
1415use OCP \Files \IRootFolder ;
1516use 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]
You canβt perform that action at this time.
0 commit comments