diff options
| author | Fuwn <[email protected]> | 2024-01-02 02:22:58 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-01-02 02:22:58 -0800 |
| commit | 67c392e288c9876e9542b7724f4f84d4c4dcd61a (patch) | |
| tree | 6054bf701b3dbd18c5f46fede5b6eae53190a98d /src/routes/completed | |
| parent | refactor(media): move hover cover (diff) | |
| download | due.moe-67c392e288c9876e9542b7724f4f84d4c4dcd61a.tar.xz due.moe-67c392e288c9876e9542b7724f4f84d4c4dcd61a.zip | |
refactor(lastactivity): move info to component
Diffstat (limited to 'src/routes/completed')
| -rw-r--r-- | src/routes/completed/+page.svelte | 46 |
1 files changed, 2 insertions, 44 deletions
diff --git a/src/routes/completed/+page.svelte b/src/routes/completed/+page.svelte index ba9243bf..0ef8f10d 100644 --- a/src/routes/completed/+page.svelte +++ b/src/routes/completed/+page.svelte @@ -4,15 +4,14 @@ import userIdentity from '$stores/userIdentity'; import settings from '$stores/settings'; import WatchingAnimeList from '$lib/List/Anime/CompletedAnimeList.svelte'; - import { lastActivityDate } from '$lib/AniList/activity'; import ListTitle from '$lib/List/ListTitle.svelte'; import MangaListTemplate from '$lib/List/Manga/MangaListTemplate.svelte'; import HeadTitle from '$lib/HeadTitle.svelte'; + import LastActivity from '$lib/LastActivity.svelte'; export let data; let currentUserIdentity = { name: '', id: -1 }; - let lastActivityWasToday = true; onMount(async () => { if ($settings.displayLimitListHeight) { @@ -30,54 +29,13 @@ currentUserIdentity = JSON.parse($userIdentity); currentUserIdentity.name = currentUserIdentity.name; - lastActivityWasToday = - (await lastActivityDate(currentUserIdentity, data.user)).date.toDateString() >= - new Date().toDateString(); - - if (!lastActivityWasToday) { - if ($settings.displayLimitListHeight) { - document.querySelectorAll('.list').forEach((list) => { - (list as HTMLElement).style.maxHeight = `calc((100vh - ${ - document.querySelector('#list-container')?.getBoundingClientRect().top - }px) - 5rem)`; - }); - } - } } }); - - const timeLeftToday = () => { - const now = new Date(); - const currentHour = now.getHours(); - const currentMinute = now.getMinutes(); - const hoursLeft = 24 - currentHour; - let minutesLeft = 0; - let timeLeft = ''; - - if (hoursLeft > 0) { - minutesLeft = hoursLeft * 60 - currentMinute; - } else { - minutesLeft = 24 * 60 - (currentHour * 60 + currentMinute); - } - - if (minutesLeft > 60) { - timeLeft = `${Math.round(minutesLeft / 60)} hours`; - } else { - timeLeft = `${minutesLeft} minutes`; - } - - return timeLeft; - }; </script> <HeadTitle route="Completed" path="/completed" /> -{#if !lastActivityWasToday} - <p> - You don't have any new activity statuses from the past day! Create one within {timeLeftToday()} - to keep your streak! - </p> -{/if} +<LastActivity user={data.user} /> <div id="list-container"> {#if data.user === undefined} |