aboutsummaryrefslogtreecommitdiff
path: root/src/lib/Hololive/Lives.svelte
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-10-09 00:41:20 -0700
committerFuwn <[email protected]>2024-10-09 00:41:43 -0700
commit998b63a35256ac985a5a2714dd1ca451af4dfd8a (patch)
tree50796121a9d5ab0330fdc5d7e098bda2860d9726 /src/lib/Hololive/Lives.svelte
parentfeat(graphql): add badgeCount field (diff)
downloaddue.moe-998b63a35256ac985a5a2714dd1ca451af4dfd8a.tar.xz
due.moe-998b63a35256ac985a5a2714dd1ca451af4dfd8a.zip
chore(prettier): use spaces instead of tabs
Diffstat (limited to 'src/lib/Hololive/Lives.svelte')
-rw-r--r--src/lib/Hololive/Lives.svelte130
1 files changed, 65 insertions, 65 deletions
diff --git a/src/lib/Hololive/Lives.svelte b/src/lib/Hololive/Lives.svelte
index 7281b18f..9e762df9 100644
--- a/src/lib/Hololive/Lives.svelte
+++ b/src/lib/Hololive/Lives.svelte
@@ -1,93 +1,93 @@
<script lang="ts">
- import Message from '$lib/Loading/Message.svelte';
- import root from '$lib/Utility/root';
- import type { Live, ParseResult } from './hololive';
- import Stream from './Stream.svelte';
+ import Message from '$lib/Loading/Message.svelte';
+ import root from '$lib/Utility/root';
+ import type { Live, ParseResult } from './hololive';
+ import Stream from './Stream.svelte';
- export let schedule: ParseResult;
- export let pinnedStreams: string[];
- export let getPinnedStreams: () => void;
- export let filter: string | undefined;
+ export let schedule: ParseResult;
+ export let pinnedStreams: string[];
+ export let getPinnedStreams: () => void;
+ export let filter: string | undefined;
- const pinStream = (streamer: string) =>
- fetch(root(`/api/preferences/pin?stream=${encodeURIComponent(streamer)}`), {
- method: 'PUT',
- headers: {
- 'Content-Type': 'application/json'
- }
- }).then(getPinnedStreams);
+ const pinStream = (streamer: string) =>
+ fetch(root(`/api/preferences/pin?stream=${encodeURIComponent(streamer)}`), {
+ method: 'PUT',
+ headers: {
+ 'Content-Type': 'application/json'
+ }
+ }).then(getPinnedStreams);
- $: categorisedStreams = schedule.lives
- .filter((live) => (filter ? live.streamer === filter : true))
- .sort((a, b) => new Date(a.time).getTime() - new Date(b.time).getTime())
- .sort((a, b) => {
- const aPinned = pinnedStreams.includes(a.streamer);
- const bPinned = pinnedStreams.includes(b.streamer);
+ $: categorisedStreams = schedule.lives
+ .filter((live) => (filter ? live.streamer === filter : true))
+ .sort((a, b) => new Date(a.time).getTime() - new Date(b.time).getTime())
+ .sort((a, b) => {
+ const aPinned = pinnedStreams.includes(a.streamer);
+ const bPinned = pinnedStreams.includes(b.streamer);
- if (aPinned && !bPinned) return -1;
- if (!aPinned && bPinned) return 1;
+ if (aPinned && !bPinned) return -1;
+ if (!aPinned && bPinned) return 1;
- return 0;
- })
- .reduce(
- (
- acc: {
- live: Live[];
- upcoming: Live[];
- ended: Live[];
- },
- live
- ) => {
- const now = Date.now();
- const time = new Date(live.time).getTime();
- const isLive = live.streaming;
- const isUpcoming = time > now && !isLive;
- const isEnded = time < now && !isLive;
+ return 0;
+ })
+ .reduce(
+ (
+ acc: {
+ live: Live[];
+ upcoming: Live[];
+ ended: Live[];
+ },
+ live
+ ) => {
+ const now = Date.now();
+ const time = new Date(live.time).getTime();
+ const isLive = live.streaming;
+ const isUpcoming = time > now && !isLive;
+ const isEnded = time < now && !isLive;
- if (isLive) {
- acc.live.push(live);
- } else if (isUpcoming) {
- acc.upcoming.push(live);
- } else if (isEnded) {
- acc.ended.push(live);
- }
+ if (isLive) {
+ acc.live.push(live);
+ } else if (isUpcoming) {
+ acc.upcoming.push(live);
+ } else if (isEnded) {
+ acc.ended.push(live);
+ }
- return acc;
- },
- { live: [], upcoming: [], ended: [] }
- );
+ return acc;
+ },
+ { live: [], upcoming: [], ended: [] }
+ );
</script>
{#if schedule.lives.length === 0}
- <Message message="No upcoming streams." loader="ripple" />
+ <Message message="No upcoming streams." loader="ripple" />
{/if}
<div class="container">
- {#each categorisedStreams.live as live}
- <Stream {live} {pinStream} {pinnedStreams} icon={schedule.dict[live.streamer]} />
- {/each}
+ {#each categorisedStreams.live as live}
+ <Stream {live} {pinStream} {pinnedStreams} icon={schedule.dict[live.streamer]} />
+ {/each}
</div>
<p />
<div class="container">
- {#each categorisedStreams.upcoming as live}
- <Stream {live} {pinStream} {pinnedStreams} icon={schedule.dict[live.streamer]} />
- {/each}
+ {#each categorisedStreams.upcoming as live}
+ <Stream {live} {pinStream} {pinnedStreams} icon={schedule.dict[live.streamer]} />
+ {/each}
</div>
<p />
<div class="container">
- {#each categorisedStreams.ended as live}
- <Stream {live} {pinStream} {pinnedStreams} icon={schedule.dict[live.streamer]} />
- {/each}
+ {#each categorisedStreams.ended as live}
+ <Stream {live} {pinStream} {pinnedStreams} icon={schedule.dict[live.streamer]} />
+ {/each}
</div>
<style lang="scss">
- .container {
- display: grid;
- grid-template-columns: repeat(auto-fill, minmax(22em, 1fr));
- gap: 0.5em;
- }
+ .container {
+ display: grid;
+ grid-template-columns: repeat(auto-fill, minmax(22em, 1fr));
+ gap: 0.5em;
+ }
</style>