mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-26 10:53:34 +03:00
fix: sort in desc based update date by default (#2510)
This commit is contained in:
parent
675c737e48
commit
be065e2de3
@ -117,7 +117,7 @@ export const PageList = ({
|
|||||||
}: PageListProps) => {
|
}: PageListProps) => {
|
||||||
const sorter = useSorter<ListData>({
|
const sorter = useSorter<ListData>({
|
||||||
data: list,
|
data: list,
|
||||||
key: 'createDate',
|
key: 'updatedDate',
|
||||||
order: 'desc',
|
order: 'desc',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ type SorterConfig<T> = {
|
|||||||
const defaultSortingFn = <T extends Record<keyof any, unknown>>(
|
const defaultSortingFn = <T extends Record<keyof any, unknown>>(
|
||||||
ctx: {
|
ctx: {
|
||||||
key: keyof T;
|
key: keyof T;
|
||||||
order: 'asc' | 'desc' | 'none';
|
order: 'asc' | 'desc';
|
||||||
},
|
},
|
||||||
a: T,
|
a: T,
|
||||||
b: T
|
b: T
|
||||||
@ -21,10 +21,10 @@ const defaultSortingFn = <T extends Record<keyof any, unknown>>(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (typeof valA === 'string') {
|
if (typeof valA === 'string') {
|
||||||
return valA.localeCompare(valB as string) * (revert ? 1 : -1);
|
return valA.localeCompare(valB as string) * (revert ? -1 : 1);
|
||||||
}
|
}
|
||||||
if (typeof valA === 'number') {
|
if (typeof valA === 'number') {
|
||||||
return valA - (valB as number) * (revert ? 1 : -1);
|
return valA - (valB as number) * (revert ? -1 : 1);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user