From 40a0ac7f201028a865bd689695a38edc97de9dcc Mon Sep 17 00:00:00 2001
From: Fuwn <contact@fuwn.me>
Date: Sat, 17 Feb 2024 17:20:48 -0800
Subject: refactor(hololive): simple sorting

---
 src/lib/Hololive/Lives.svelte | 24 +++++-------------------
 1 file changed, 5 insertions(+), 19 deletions(-)

(limited to 'src/lib/Hololive/Lives.svelte')

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(
 			(
-- 
cgit v1.2.3

