diff --git a/src/hooks/live-streams.ts b/src/hooks/live-streams.ts index ee56ee4..b39977f 100644 --- a/src/hooks/live-streams.ts +++ b/src/hooks/live-streams.ts @@ -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 [];