diff options
| author | Fuwn <[email protected]> | 2023-12-24 03:11:43 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-12-24 03:11:43 -0800 |
| commit | 772c1e5e101adc0f6bab770981ac634653fd5fce (patch) | |
| tree | 8c61d2f3ebefad6b19ad81ff73407bb46a57a847 /src/lib/Tools | |
| parent | refactor(tools): rename birthdays (diff) | |
| download | due.moe-772c1e5e101adc0f6bab770981ac634653fd5fce.tar.xz due.moe-772c1e5e101adc0f6bab770981ac634653fd5fce.zip | |
fix(wrapped): null check top media
Diffstat (limited to 'src/lib/Tools')
| -rw-r--r-- | src/lib/Tools/Wrapped.svelte | 120 |
1 files changed, 64 insertions, 56 deletions
diff --git a/src/lib/Tools/Wrapped.svelte b/src/lib/Tools/Wrapped.svelte index 28749d26..58a4cafb 100644 --- a/src/lib/Tools/Wrapped.svelte +++ b/src/lib/Tools/Wrapped.svelte @@ -516,66 +516,74 @@ <div class="categories-grid" style="padding-top: 0;"> <div class="category-grid pure-category category"> <div class="grid-item image-grid"> - <a - href={`https://anilist.co/${topMedia.topGenreMedia.type.toLowerCase()}/${ - topMedia.topGenreMedia.id - }`} - target="_blank" - > - <img - src={proxy(topMedia.topGenreMedia.coverImage.extraLarge)} - alt="Highest Rated Genre Cover" - class="cover-image" - on:load={updateWidth} - /> - </a> - <div> - <b>Highest Rated Genres</b> - <ol> - {#each topMedia.genres as genre} - <li> - <a - href={`https://anilist.co/search/anime?genres=${genre.genre}`} - target="_blank" - > - {genre.genre}: {genre.averageScore}% - </a> - </li> - {/each} - </ol> - </div> + {#if topMedia} + <a + href={`https://anilist.co/${topMedia.topGenreMedia.type.toLowerCase()}/${ + topMedia.topGenreMedia.id + }`} + target="_blank" + > + <img + src={proxy(topMedia.topGenreMedia.coverImage.extraLarge)} + alt="Highest Rated Genre Cover" + class="cover-image" + on:load={updateWidth} + /> + </a> + <div> + <b>Highest Rated Genres</b> + <ol> + {#each topMedia.genres as genre} + <li> + <a + href={`https://anilist.co/search/anime?genres=${genre.genre}`} + target="_blank" + > + {genre.genre}: {genre.averageScore}% + </a> + </li> + {/each} + </ol> + </div> + {:else} + {@html nbsp('Loading top genres ...')} + {/if} </div> </div> <div class="category-grid pure-category category"> <div class="grid-item image-grid"> - <a - href={`https://anilist.co/${topMedia.topTagMedia.type.toLowerCase()}/${ - topMedia.topTagMedia.id - }`} - target="_blank" - > - <img - src={proxy(topMedia.topTagMedia.coverImage.extraLarge)} - alt="Highest Rated Tag Cover" - class="cover-image" - on:load={updateWidth} - /> - </a> - <div> - <b>Highest Rated Tags</b> - <ol> - {#each topMedia.tags as tag} - <li> - <a - href={`https://anilist.co/search/anime?genres=${tag.tag}`} - target="_blank" - > - {tag.tag}: {tag.averageScore}% - </a> - </li> - {/each} - </ol> - </div> + {#if topMedia} + <a + href={`https://anilist.co/${topMedia.topTagMedia.type.toLowerCase()}/${ + topMedia.topTagMedia.id + }`} + target="_blank" + > + <img + src={proxy(topMedia.topTagMedia.coverImage.extraLarge)} + alt="Highest Rated Tag Cover" + class="cover-image" + on:load={updateWidth} + /> + </a> + <div> + <b>Highest Rated Tags</b> + <ol> + {#each topMedia.tags as tag} + <li> + <a + href={`https://anilist.co/search/anime?genres=${tag.tag}`} + target="_blank" + > + {tag.tag}: {tag.averageScore}% + </a> + </li> + {/each} + </ol> + </div> + {:else} + {@html nbsp('Loading top tags ...')} + {/if} </div> </div> </div> |