sort ended by last updated

This commit is contained in:
Kieran 2023-08-04 16:20:08 +01:00
parent 2c39bdc104
commit 14aeff4a80
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941

View File

@ -28,15 +28,13 @@ export function useStreamsFeed(tag?: string) {
const feedSorted = useMemo(() => {
if (feed.data) {
return [...feed.data].sort((a, b) => {
const aStatus = findTag(a, "status")!;
const bStatus = findTag(b, "status")!;
if (aStatus === bStatus) {
const aStart = Number(findTag(a, "starts") ?? "0");
const bStart = Number(findTag(b, "starts") ?? "0");
return bStart > aStart ? 1 : -1;
} else {
return aStatus === "live" ? -1 : 1;
const status = findTag(a, "status");
if (status === StreamState.Ended) {
return b.created_at > a.created_at ? 1 : -1;
}
const aStart = Number(findTag(a, "starts") ?? "0");
const bStart = Number(findTag(b, "starts") ?? "0");
return bStart > aStart ? 1 : -1;
});
}
return [];