diff options
| author | Fuwn <[email protected]> | 2023-12-13 18:54:35 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-12-13 18:54:35 -0800 |
| commit | 77332f34ae861f1a78acd1e74011299a8bb35665 (patch) | |
| tree | 65fb9d16aac7ffed6dae46ba6222cb4c32d8197d | |
| parent | style(AniList): simplify (diff) | |
| download | due.moe-77332f34ae861f1a78acd1e74011299a8bb35665.tar.xz due.moe-77332f34ae861f1a78acd1e74011299a8bb35665.zip | |
style(Media): simplify statements
| -rw-r--r-- | src/lib/Media/anime.ts | 9 | ||||
| -rw-r--r-- | src/lib/Media/manga.ts | 35 | ||||
| -rw-r--r-- | src/lib/Media/media.ts | 5 |
3 files changed, 14 insertions, 35 deletions
diff --git a/src/lib/Media/anime.ts b/src/lib/Media/anime.ts index 937e9dac..0cc854e7 100644 --- a/src/lib/Media/anime.ts +++ b/src/lib/Media/anime.ts @@ -47,9 +47,7 @@ export const airingTime = (anime: Media, upcoming = false) => { timeFrame = `${days.toFixed(0)} day${days === 1 ? '' : 's'}`; // } - } else { - timeFrame = `${hours.toFixed(1)} hour${hours === 1 ? '' : 's'}`; - } + } else timeFrame = `${hours.toFixed(1)} hour${hours === 1 ? '' : 's'}`; } else { minutes = Math.round(minutes); @@ -58,19 +56,18 @@ export const airingTime = (anime: Media, upcoming = false) => { const opacity = Math.max(50, 100 - (untilAiring / 60 / 60 / 24 / 7) * 50); - if (upcoming) { + if (upcoming) return `<span title="${ hours ? `${hours.toFixed(3)} hours` : '' }" style="opacity: ${opacity}%">${anime.nextAiringEpisode?.episode}${totalEpisodes( anime )} in ${timeFrame} <span style="opacity: 50%">${few ? `(${time})` : ''}</span></span>`; - } else { + else return `<span title="${ hours ? `${hours.toFixed(3)} hours` : '' }" style="opacity: ${opacity}%">${anime.nextAiringEpisode?.episode} in ${ few ? '<b>' : '' }${timeFrame}${few ? '</b>' : ''} ${few ? `(${time})` : ''}</span>`; - } } return ''; diff --git a/src/lib/Media/manga.ts b/src/lib/Media/manga.ts index b8afbc96..8842d9d9 100644 --- a/src/lib/Media/manga.ts +++ b/src/lib/Media/manga.ts @@ -23,18 +23,14 @@ export const chapterCount = async ( ): Promise<number | null> => { const chapters = await chapterDatabase.chapters.get(manga.id); - if (chapters !== undefined) { - return chapters.chapters === -1 ? null : chapters.chapters; - } + if (chapters !== undefined) return chapters.chapters === -1 ? null : chapters.chapters; // if (preferActivity) { // return await recentMediaActivities(identity, manga); // } const tryRecentMediaActivities = async () => { - if (disableGuessing) { - return null; - } + if (disableGuessing) return null; const anilistData = await recentMediaActivities(identity, manga, settings.get().guessMethod); @@ -47,9 +43,7 @@ export const chapterCount = async ( return anilistData; }; - if (manga.format === 'NOVEL') { - return await tryRecentMediaActivities(); - } + if (manga.format === 'NOVEL') return await tryRecentMediaActivities(); const mangadexData = await fetch( `/api/mangadex/manga?english=${manga.title.english}&year=${manga.startDate.year}&romaji=${manga.title.romaji}&native=${manga.title.native}&status=${manga.status}` @@ -78,9 +72,7 @@ export const chapterCount = async ( if ((manga.mediaListEntry || { progress: 0 }).progress > lastChapter) { const anilistData = await recentMediaActivities(identity, manga, settings.get().guessMethod); - if (anilistData !== null && anilistData > lastChapter) { - lastChapter = anilistData; - } + if (anilistData !== null && anilistData > lastChapter) lastChapter = anilistData; } if (!settings.get().disableOutOfDateVolumeWarning) { @@ -88,9 +80,7 @@ export const chapterCount = async ( `/api/mangadex/chapter?id=${mangadexId}&chapter=${manga.mediaListEntry?.progress}` ); - if ((await volumeOfChapterDataResponse.clone().text()) === 'rate-limited') { - return -22; - } + if ((await volumeOfChapterDataResponse.clone().text()) === 'rate-limited') return -22; const volumeOfChapterData = await volumeOfChapterDataResponse.json(); let lastAvailableVolume = lastChapterDataJson['data'][0]['attributes']['volume']; @@ -99,9 +89,8 @@ export const chapterCount = async ( let chapterIndex = 0; while (chapterIndex < lastChapterDataJson['data'].length && lastAvailableVolume === null) { - if (lastChapterDataJson['data'][chapterIndex]['attributes']['volume'] !== null) { + if (lastChapterDataJson['data'][chapterIndex]['attributes']['volume'] !== null) lastAvailableVolume = lastChapterDataJson['data'][chapterIndex]['attributes']['volume']; - } chapterIndex += 1; } @@ -110,19 +99,13 @@ export const chapterCount = async ( if (volumeOfChapterData['data'] !== undefined && volumeOfChapterData['data'].length > 0) { const volumeOfChapter = volumeOfChapterData['data'][0]['attributes']['volume']; - if (volumeOfChapter !== null) { - completedVolumes = volumeOfChapter; - } + if (volumeOfChapter !== null) completedVolumes = volumeOfChapter; - if (completedVolumes === volumeOfChapter) { - completedVolumes -= 1; - } + if (completedVolumes === volumeOfChapter) completedVolumes -= 1; } } - if (lastChapter == 0) { - lastChapter = -1; - } + if (lastChapter == 0) lastChapter = -1; await chapterDatabase.chapters.put({ id: manga.id, diff --git a/src/lib/Media/media.ts b/src/lib/Media/media.ts index a98d5d07..eac4ad6a 100644 --- a/src/lib/Media/media.ts +++ b/src/lib/Media/media.ts @@ -5,7 +5,7 @@ export const outboundLink = ( type: 'anime' | 'manga', setting: 'anilist' | 'livechartme' | 'animeschedule' | 'myanimelist' ) => { - if (type === 'manga') { + if (type === 'manga') switch (setting) { case 'livechartme': case 'animeschedule': @@ -17,7 +17,7 @@ export const outboundLink = ( default: return `https://anilist.co/${type}/${media.id}`; } - } else { + else switch (setting) { case 'anilist': return `https://anilist.co/${type}/${media.id}`; @@ -38,5 +38,4 @@ export const outboundLink = ( media.title.native || media.title.english || media.title.romaji }`; } - } }; |