perf: Move collection sorting to frontend (#3475)
* perf: Move collection sorting to frontend, on demand, memoized * fix: Add default
This commit is contained in:
@@ -8,7 +8,8 @@ type Sort = {
|
||||
|
||||
export const sortNavigationNodes = (
|
||||
documents: NavigationNode[],
|
||||
sort: Sort
|
||||
sort: Sort,
|
||||
sortChildren = true
|
||||
): NavigationNode[] => {
|
||||
// "index" field is manually sorted and is represented by the documentStructure
|
||||
// already saved in the database, no further sort is needed
|
||||
@@ -22,6 +23,8 @@ export const sortNavigationNodes = (
|
||||
|
||||
return orderedDocs.map((document) => ({
|
||||
...document,
|
||||
children: sortNavigationNodes(document.children, sort),
|
||||
children: sortChildren
|
||||
? sortNavigationNodes(document.children, sort, sortChildren)
|
||||
: document.children,
|
||||
}));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user