diff options
| author | Fuwn <[email protected]> | 2024-02-17 17:20:48 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-02-17 17:20:48 -0800 |
| commit | 40a0ac7f201028a865bd689695a38edc97de9dcc (patch) | |
| tree | 97bf5d260e62e58317d8077d80e179a05030b31b /src/lib | |
| parent | feat(hololive): seperate categories (diff) | |
| download | due.moe-40a0ac7f201028a865bd689695a38edc97de9dcc.tar.xz due.moe-40a0ac7f201028a865bd689695a38edc97de9dcc.zip | |
refactor(hololive): simple sorting
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/Hololive/Lives.svelte | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/src/lib/Hololive/Lives.svelte b/src/lib/Hololive/Lives.svelte index 38def6fa..31843be2 100644 --- a/src/lib/Hololive/Lives.svelte +++ b/src/lib/Hololive/Lives.svelte @@ -20,27 +20,13 @@ $: categorisedStreams = schedule.lives .sort((a, b) => new Date(a.time).getTime() - new Date(b.time).getTime()) .sort((a, b) => { - const now = Date.now(); - const aTime = new Date(a.time).getTime(); - const bTime = new Date(b.time).getTime(); - const aIsLive = a.streaming; - const bIsLive = b.streaming; - const aIsClosestPinned = closestUpcomingPinnedStreams.get(a.streamer) === a; - const bIsClosestPinned = closestUpcomingPinnedStreams.get(b.streamer) === b; + const aPinned = pinnedStreams.includes(a.streamer); + const bPinned = pinnedStreams.includes(b.streamer); - if (aIsLive && pinnedStreams.includes(a.streamer)) return -1; - if (bIsLive && pinnedStreams.includes(b.streamer)) return 1; + if (aPinned && !bPinned) return -1; + if (!aPinned && bPinned) return 1; - if (aIsLive && !bIsLive) return -1; - if (bIsLive && !aIsLive) return 1; - - if (aIsClosestPinned && !bIsClosestPinned) return -1; - if (bIsClosestPinned && !aIsClosestPinned) return 1; - - if (aTime > now && !(aTime < now && !aIsLive)) return -1; - if (bTime > now && !(bTime < now && !bIsLive)) return 1; - - return bTime - aTime; + return 0; }) .reduce( ( |