perf: Move collection sorting to frontend (#3475)
* perf: Move collection sorting to frontend, on demand, memoized * fix: Add default
This commit is contained in:
@@ -161,6 +161,7 @@ class Collection extends ParanoidModel {
|
||||
@Column
|
||||
sharing: boolean;
|
||||
|
||||
@Default({ field: "title", direction: "asc" })
|
||||
@Column({
|
||||
type: DataType.JSONB,
|
||||
validate: {
|
||||
@@ -184,7 +185,7 @@ class Collection extends ParanoidModel {
|
||||
},
|
||||
},
|
||||
})
|
||||
sort: Sort | null;
|
||||
sort: Sort;
|
||||
|
||||
// getters
|
||||
|
||||
@@ -362,10 +363,6 @@ class Collection extends ParanoidModel {
|
||||
if (!this.documentStructure) {
|
||||
return null;
|
||||
}
|
||||
const sort: Sort = this.sort || {
|
||||
field: "title",
|
||||
direction: "asc",
|
||||
};
|
||||
|
||||
let result!: NavigationNode | undefined;
|
||||
|
||||
@@ -399,7 +396,7 @@ class Collection extends ParanoidModel {
|
||||
|
||||
return {
|
||||
...result,
|
||||
children: sortNavigationNodes(result.children, sort),
|
||||
children: sortNavigationNodes(result.children, this.sort),
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user