aboutsummaryrefslogtreecommitdiff
path: root/src/lib/List
diff options
context:
space:
mode:
authorFuwn <[email protected]>2023-12-16 18:50:51 -0800
committerFuwn <[email protected]>2023-12-16 18:50:51 -0800
commitb018bd62213b1a72114ecf47c6676204e33bd429 (patch)
tree8b8ece187917e99fc5591fe2f5fa271861e8b260 /src/lib/List
parentfeat(api): subsplease endpoint (diff)
downloaddue.moe-b018bd62213b1a72114ecf47c6676204e33bd429.tar.xz
due.moe-b018bd62213b1a72114ecf47c6676204e33bd429.zip
feat(anime): subtitle countdown
Diffstat (limited to 'src/lib/List')
-rw-r--r--src/lib/List/Anime/CleanAnimeList.svelte67
1 files changed, 36 insertions, 31 deletions
diff --git a/src/lib/List/Anime/CleanAnimeList.svelte b/src/lib/List/Anime/CleanAnimeList.svelte
index 0b130d15..fd31963c 100644
--- a/src/lib/List/Anime/CleanAnimeList.svelte
+++ b/src/lib/List/Anime/CleanAnimeList.svelte
@@ -8,7 +8,8 @@
import ListTitle from '../ListTitle.svelte';
import MediaTitle from '../MediaTitleDisplay.svelte';
import { outboundLink } from '$lib/Media/media';
- import { onDestroy } from 'svelte';
+ import { onDestroy, onMount } from 'svelte';
+ import type { SubsPlease } from '$lib/subsPlease';
export let media: Media[];
export let title: string;
@@ -73,42 +74,46 @@
{#if title !== 'Upcoming Episodes' || !$settings.displayCountdownRightAligned}
<span style="opacity: 50%;">|</span>
{/if}
- {#if title !== 'Upcoming Episodes'}
- <!-- {anime.mediaListEntry?.progress || 0}{@html totalEpisodes(anime)} -->
- {pendingUpdate === anime.id ? progress + 1 : progress}{@html totalEpisodes(anime)}
- <a
- href={'#'}
- style={pendingUpdate === anime.id ? 'pointer-events: none; opacity: 50%;' : ''}
- on:click={() => {
- if (pendingUpdate !== anime.id) {
- lastUpdatedMedia = anime.id;
- pendingUpdate = anime.id;
+ {#await fetch(`/api/subsplease?tz=${Intl.DateTimeFormat().resolvedOptions().timeZone}`).then( (r) => r.json() )}
+ Loading ...
+ {:then subsPlease}
+ {#if title !== 'Upcoming Episodes'}
+ <!-- {anime.mediaListEntry?.progress || 0}{@html totalEpisodes(anime)} -->
+ {pendingUpdate === anime.id ? progress + 1 : progress}{@html totalEpisodes(anime)}
+ <a
+ href={'#'}
+ style={pendingUpdate === anime.id ? 'pointer-events: none; opacity: 50%;' : ''}
+ on:click={() => {
+ if (pendingUpdate !== anime.id) {
+ lastUpdatedMedia = anime.id;
+ pendingUpdate = anime.id;
- updateMedia(anime.id, anime.mediaListEntry?.progress, () => {
- const mediaListEntry = media.find((m) => m.id === anime.id)?.mediaListEntry;
+ updateMedia(anime.id, anime.mediaListEntry?.progress, () => {
+ const mediaListEntry = media.find((m) => m.id === anime.id)?.mediaListEntry;
- if (mediaListEntry) mediaListEntry.progress = progress + 1;
+ if (mediaListEntry) mediaListEntry.progress = progress + 1;
- previousAnimeList = media;
- animeLists = cleanCache(user, identity);
- pendingUpdate = null;
- });
- }
- }}>+</a
- >
- {#if !completed}
- [{anime.nextAiringEpisode?.episode === -1
- ? '?'
- : (anime.nextAiringEpisode?.episode || 1) - 1}]
+ previousAnimeList = media;
+ animeLists = cleanCache(user, identity);
+ pendingUpdate = null;
+ });
+ }
+ }}>+</a
+ >
+ {#if !completed}
+ [{anime.nextAiringEpisode?.episode === -1
+ ? '?'
+ : (anime.nextAiringEpisode?.episode || 1) - 1}]
+ <span class:countdown={$settings.displayCountdownRightAligned}>
+ {@html airingTime(anime, subsPlease)}
+ </span>
+ {/if}
+ {:else}
<span class:countdown={$settings.displayCountdownRightAligned}>
- {@html airingTime(anime)}
+ {@html airingTime(anime, subsPlease, true)}
</span>
{/if}
- {:else}
- <span class:countdown={$settings.displayCountdownRightAligned}>
- {@html airingTime(anime, true)}
- </span>
- {/if}
+ {/await}
</span>
</li>
{/if}