perf: Move collection sorting to frontend (#3475)
* perf: Move collection sorting to frontend, on demand, memoized * fix: Add default
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
import { sortNavigationNodes } from "@shared/utils/collections";
|
||||
import { APM } from "@server/logging/tracing";
|
||||
import Collection from "@server/models/Collection";
|
||||
|
||||
function present(collection: Collection) {
|
||||
const data = {
|
||||
return {
|
||||
id: collection.id,
|
||||
url: collection.url,
|
||||
urlId: collection.urlId,
|
||||
@@ -20,21 +19,6 @@ function present(collection: Collection) {
|
||||
deletedAt: collection.deletedAt,
|
||||
documents: collection.documentStructure,
|
||||
};
|
||||
|
||||
// Handle the "sort" field being empty here for backwards compatability
|
||||
if (!data.sort) {
|
||||
data.sort = {
|
||||
field: "title",
|
||||
direction: "asc",
|
||||
};
|
||||
}
|
||||
|
||||
data.documents = sortNavigationNodes(
|
||||
collection.documentStructure || [],
|
||||
data.sort
|
||||
);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
export default APM.traceFunction({
|
||||
|
||||
Reference in New Issue
Block a user