implmenet custom sort to replace images adapter logic

This commit is contained in:
Mary Hipp
2024-06-23 19:26:04 -04:00
committed by psychedelicious
parent 719c066ac4
commit 7bbe236107
2 changed files with 16 additions and 2 deletions

View File

@@ -75,6 +75,19 @@ export const imagesAdapter = createEntityAdapter<ImageDTO, string>({
},
});
export const imageListDefaultSort = () => {
return (a: ImageDTO, b: ImageDTO) => {
if (a.starred && !b.starred) {
return -1;
}
if (!a.starred && b.starred) {
return 1;
}
return dateComparator(b.created_at, a.created_at);
}
}
// Create selectors for the adapter.
export const imagesSelectors = imagesAdapter.getSelectors(undefined, getSelectorsOptions);