aboutsummaryrefslogtreecommitdiff
path: root/src/lib/Tools/EpisodeDiscussionCollector.svelte
blob: 71e13addbc5109444751c4e33833227530089f8a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<script lang="ts">
  import Spacer from '$lib/Layout/Spacer.svelte';
  import { threads } from '$lib/Data/AniList/forum';
  import { onMount } from 'svelte';
  import { clearAllParameters } from '../Utility/parameters';
  import Skeleton from '$lib/Loading/Skeleton.svelte';
  import InputTemplate from './InputTemplate.svelte';
  import tooltip from '$lib/Tooltip/tooltip';

  let submission = '';

  onMount(clearAllParameters);
</script>

<InputTemplate
  field="Username"
  bind:submission
  event="Collect Episode Discussions"
  submitText="Search"
>
  {#if submission !== ''}
    {#await threads(submission)}
      <Skeleton card={false} count={5} height="0.9rem" list />
    {:then threads}
      <ol reversed>
        {#each threads
          .filter( (thread) => thread.categories.some( (category) => category.name.includes('Release Discussion') ) )
          .sort((a, b) => b.createdAt - a.createdAt) as thread}
          <li>
            <span class="opaque" style="white-space: pre;">
              {new Date(thread.createdAt * 1000).toLocaleDateString('en-US', {
                month: 'short',
                day: 'numeric',
                year: 'numeric'
              })}
            </span>
            <a
              href={`https://anilist.co/forum/thread/${thread.id}`}
              target="_blank"
              title={`<img src="${thread.mediaCategories[0].coverImage.extraLarge}" style="width: 250px; object-fit: cover; border-radius: 8px;" />`}
              use:tooltip
            >
              {thread.title.replace('[Spoilers]', '')}
            </a>
          </li>
        {/each}
      </ol>
    {:catch}
      <p>Threads could not be loaded. You might have been rate-limited.</p>
      <p>
        Try again in a few minutes. If the problem persists, please contact <a
          href="https://anilist.co/user/fuwn"
          target="_blank">@fuwn</a
        > on AniList.
      </p>
    {/await}
  {:else}
    <Spacer />

    Enter a username to search for to continue.
  {/if}
</InputTemplate>