From 27e4481ae778deb3a4b7a788d1154dc53f3107b9 Mon Sep 17 00:00:00 2001 From: Kevin Hoang Date: Tue, 12 Dec 2023 03:54:42 -0600 Subject: [PATCH] Fixed completed for SplitCompletedList --- src/renderer/functions/CheckForListFlags.ts | 464 ++++++++++++++++++ .../functions/MainMediaListFunctions.tsx | 112 +++-- 2 files changed, 519 insertions(+), 57 deletions(-) create mode 100644 src/renderer/functions/CheckForListFlags.ts diff --git a/src/renderer/functions/CheckForListFlags.ts b/src/renderer/functions/CheckForListFlags.ts new file mode 100644 index 0000000..7d90c88 --- /dev/null +++ b/src/renderer/functions/CheckForListFlags.ts @@ -0,0 +1,464 @@ +export function getListForCompletedAnime( + myQuery: any, + animeCompletedIndex: any, + animeSplitCompletedListFlag: Boolean, + animeSplitArray: any, +) { + console.log(animeCompletedIndex); + console.log(animeSplitCompletedListFlag); + console.log(animeSplitArray); + if (animeCompletedIndex !== null && animeSplitCompletedListFlag === false) { + return myQuery[animeCompletedIndex].entries.map( + (entry: any, index: any) => ({ + id: entry.media.id, + idMal: entry.media.idMal, + private: entry.private, + titleRomaji: entry.media.title.romaji, + titleEnglish: entry.media.title.english, + titleNative: entry.media.title.native, + synonyms: entry.media.synonyms, + season: entry.media.season, + seasonYear: entry.media.seasonYear, + episodes: entry.media.episodes, + chapters: entry.media.chapters, + volumes: entry.media.volumes, + type: entry.media.type, + format: entry.media.format, + image: entry.media.coverImage.large, + imageMedium: entry.media.coverImage.medium, + imageExtraLarge: entry.media.coverImage.extraLarge, + bannerImage: entry.media.bannerImage, + startYear: entry.media.startDate.year, + startMonth: entry.media.startDate.month, + startDay: entry.media.startDate.day, + description: entry.media.description, + genres: entry.media.genres, + tags: entry.media.tags, + status: entry.media.status, + siteUrl: entry.media.siteUrl, + duration: entry.media.duration, + averageScore: entry.media.averageScore, + popularity: entry.media.popularity, + studios: entry.media.studios.edges, + mainStudioIndex: entry.media.studios.edges + .map((e: any) => { + return e.isMain; + }) + .indexOf(true), + source: entry.media.source, + meanScore: entry.media.meanScore, + mediaListEntry: entry.media.mediaListEntry, + progress: entry.media.mediaListEntry.progress, + progressVolumes: entry.media.mediaListEntry.progressVolumes, + score: entry.media.mediaListEntry.score, + notes: entry.media.mediaListEntry.notes, + startedAt: entry.media.mediaListEntry.startedAt, + completedAt: entry.media.mediaListEntry.completedAt, + repeat: entry.media.mediaListEntry.repeat, + trailer: entry.media.trailer, + nextAiringEpisode: entry.media.nextAiringEpisode, + location: 'animeCompleted', + key: entry.media.title.romaji + entry.media.id, + }), + ); + } + + const accumulator: any = []; + if (animeCompletedIndex !== null && animeSplitCompletedListFlag === true) { + // eslint-disable-next-line no-plusplus + for (let i = 0; i < animeSplitArray.length; i++) { + // eslint-disable-next-line no-plusplus + for (let j = 0; j < myQuery[animeSplitArray[i]].entries.length; j++) { + accumulator.push({ + id: myQuery[animeSplitArray[i]].entries[j].media.id, + idMal: myQuery[animeSplitArray[i]].entries[j].media.idMal, + private: myQuery[animeSplitArray[i]].entries[j].private, + titleRomaji: + myQuery[animeSplitArray[i]].entries[j].media.title.romaji, + titleEnglish: + myQuery[animeSplitArray[i]].entries[j].media.title.english, + titleNative: + myQuery[animeSplitArray[i]].entries[j].media.title.native, + synonyms: myQuery[animeSplitArray[i]].entries[j].media.synonyms, + season: myQuery[animeSplitArray[i]].entries[j].media.season, + seasonYear: myQuery[animeSplitArray[i]].entries[j].media.seasonYear, + episodes: myQuery[animeSplitArray[i]].entries[j].media.episodes, + chapters: myQuery[animeSplitArray[i]].entries[j].media.chapters, + volumes: myQuery[animeSplitArray[i]].entries[j].media.volumes, + type: myQuery[animeSplitArray[i]].entries[j].media.type, + format: myQuery[animeSplitArray[i]].entries[j].media.format, + image: myQuery[animeSplitArray[i]].entries[j].media.coverImage.large, + imageMedium: + myQuery[animeSplitArray[i]].entries[j].media.coverImage.medium, + imageExtraLarge: + myQuery[animeSplitArray[i]].entries[j].media.coverImage.extraLarge, + bannerImage: myQuery[animeSplitArray[i]].entries[j].media.bannerImage, + startYear: + myQuery[animeSplitArray[i]].entries[j].media.startDate.year, + startMonth: + myQuery[animeSplitArray[i]].entries[j].media.startDate.month, + startDay: myQuery[animeSplitArray[i]].entries[j].media.startDate.day, + description: myQuery[animeSplitArray[i]].entries[j].media.description, + genres: myQuery[animeSplitArray[i]].entries[j].media.genres, + tags: myQuery[animeSplitArray[i]].entries[j].media.tags, + status: myQuery[animeSplitArray[i]].entries[j].media.status, + siteUrl: myQuery[animeSplitArray[i]].entries[j].media.siteUrl, + duration: myQuery[animeSplitArray[i]].entries[j].media.duration, + averageScore: + myQuery[animeSplitArray[i]].entries[j].media.averageScore, + popularity: myQuery[animeSplitArray[i]].entries[j].media.popularity, + studios: myQuery[animeSplitArray[i]].entries[j].media.studios.edges, + mainStudioIndex: myQuery[animeSplitArray[i]].entries[ + j + ].media.studios.edges + .map((e: any) => { + return e.isMain; + }) + .indexOf(true), + source: myQuery[animeSplitArray[i]].entries[j].media.source, + meanScore: myQuery[animeSplitArray[i]].entries[j].media.meanScore, + mediaListEntry: + myQuery[animeSplitArray[i]].entries[j].media.mediaListEntry, + progress: + myQuery[animeSplitArray[i]].entries[j].media.mediaListEntry + .progress, + progressVolumes: + myQuery[animeSplitArray[i]].entries[j].media.mediaListEntry + .progressVolumes, + score: + myQuery[animeSplitArray[i]].entries[j].media.mediaListEntry.score, + notes: + myQuery[animeSplitArray[i]].entries[j].media.mediaListEntry.notes, + startedAt: + myQuery[animeSplitArray[i]].entries[j].media.mediaListEntry + .startedAt, + completedAt: + myQuery[animeSplitArray[i]].entries[j].media.mediaListEntry + .completedAt, + repeat: + myQuery[animeSplitArray[i]].entries[j].media.mediaListEntry.repeat, + trailer: myQuery[animeSplitArray[i]].entries[j].media.trailer, + nextAiringEpisode: + myQuery[animeSplitArray[i]].entries[j].media.nextAiringEpisode, + location: 'animeCompleted', + key: + myQuery[animeSplitArray[i]].entries[j].media.title.romaji + + myQuery[animeSplitArray[i]].entries[j].media.id, + }); + } + } + return accumulator; + } + + return []; +} + +export function getListForCompletedManga( + myQuery: any, + mangaCompletedIndex: any, + mangaSplitCompletedListFlag: Boolean, + mangaSplitArray: any, +) { + console.log(mangaCompletedIndex); + console.log(mangaSplitCompletedListFlag); + console.log(mangaSplitArray); + if (mangaCompletedIndex !== null && mangaSplitCompletedListFlag === false) { + return myQuery[mangaCompletedIndex].entries.map( + (entry: any, index: any) => ({ + id: entry.media.id, + idMal: entry.media.idMal, + private: entry.private, + titleRomaji: entry.media.title.romaji, + titleEnglish: entry.media.title.english, + titleNative: entry.media.title.native, + synonyms: entry.media.synonyms, + season: entry.media.season, + seasonYear: entry.media.seasonYear, + episodes: entry.media.episodes, + chapters: entry.media.chapters, + volumes: entry.media.volumes, + type: entry.media.type, + format: entry.media.format, + image: entry.media.coverImage.large, + imageMedium: entry.media.coverImage.medium, + imageExtraLarge: entry.media.coverImage.extraLarge, + bannerImage: entry.media.bannerImage, + startYear: entry.media.startDate.year, + startMonth: entry.media.startDate.month, + startDay: entry.media.startDate.day, + description: entry.media.description, + genres: entry.media.genres, + tags: entry.media.tags, + status: entry.media.status, + siteUrl: entry.media.siteUrl, + duration: entry.media.duration, + averageScore: entry.media.averageScore, + popularity: entry.media.popularity, + studios: entry.media.studios.edges, + mainStudioIndex: entry.media.studios.edges + .map((e: any) => { + return e.isMain; + }) + .indexOf(true), + source: entry.media.source, + meanScore: entry.media.meanScore, + mediaListEntry: entry.media.mediaListEntry, + progress: entry.media.mediaListEntry.progress, + progressVolumes: entry.media.mediaListEntry.progressVolumes, + score: entry.media.mediaListEntry.score, + notes: entry.media.mediaListEntry.notes, + startedAt: entry.media.mediaListEntry.startedAt, + completedAt: entry.media.mediaListEntry.completedAt, + repeat: entry.media.mediaListEntry.repeat, + trailer: entry.media.trailer, + nextAiringEpisode: entry.media.nextAiringEpisode, + location: 'mangaCompleted', + key: entry.media.title.romaji + entry.media.id, + }), + ); + } + + const accumulator: any = []; + if (mangaCompletedIndex !== null && mangaSplitCompletedListFlag === true) { + // eslint-disable-next-line no-plusplus + for (let i = 0; i < mangaSplitArray.length; i++) { + // eslint-disable-next-line no-plusplus + for (let j = 0; j < myQuery[mangaSplitArray[i]].entries.length; j++) { + accumulator.push({ + id: myQuery[mangaSplitArray[i]].entries[j].media.id, + idMal: myQuery[mangaSplitArray[i]].entries[j].media.idMal, + private: myQuery[mangaSplitArray[i]].entries[j].private, + titleRomaji: + myQuery[mangaSplitArray[i]].entries[j].media.title.romaji, + titleEnglish: + myQuery[mangaSplitArray[i]].entries[j].media.title.english, + titleNative: + myQuery[mangaSplitArray[i]].entries[j].media.title.native, + synonyms: myQuery[mangaSplitArray[i]].entries[j].media.synonyms, + season: myQuery[mangaSplitArray[i]].entries[j].media.season, + seasonYear: myQuery[mangaSplitArray[i]].entries[j].media.seasonYear, + episodes: myQuery[mangaSplitArray[i]].entries[j].media.episodes, + chapters: myQuery[mangaSplitArray[i]].entries[j].media.chapters, + volumes: myQuery[mangaSplitArray[i]].entries[j].media.volumes, + type: myQuery[mangaSplitArray[i]].entries[j].media.type, + format: myQuery[mangaSplitArray[i]].entries[j].media.format, + image: myQuery[mangaSplitArray[i]].entries[j].media.coverImage.large, + imageMedium: + myQuery[mangaSplitArray[i]].entries[j].media.coverImage.medium, + imageExtraLarge: + myQuery[mangaSplitArray[i]].entries[j].media.coverImage.extraLarge, + bannerImage: myQuery[mangaSplitArray[i]].entries[j].media.bannerImage, + startYear: + myQuery[mangaSplitArray[i]].entries[j].media.startDate.year, + startMonth: + myQuery[mangaSplitArray[i]].entries[j].media.startDate.month, + startDay: myQuery[mangaSplitArray[i]].entries[j].media.startDate.day, + description: myQuery[mangaSplitArray[i]].entries[j].media.description, + genres: myQuery[mangaSplitArray[i]].entries[j].media.genres, + tags: myQuery[mangaSplitArray[i]].entries[j].media.tags, + status: myQuery[mangaSplitArray[i]].entries[j].media.status, + siteUrl: myQuery[mangaSplitArray[i]].entries[j].media.siteUrl, + duration: myQuery[mangaSplitArray[i]].entries[j].media.duration, + averageScore: + myQuery[mangaSplitArray[i]].entries[j].media.averageScore, + popularity: myQuery[mangaSplitArray[i]].entries[j].media.popularity, + studios: myQuery[mangaSplitArray[i]].entries[j].media.studios.edges, + mainStudioIndex: myQuery[mangaSplitArray[i]].entries[ + j + ].media.studios.edges + .map((e: any) => { + return e.isMain; + }) + .indexOf(true), + source: myQuery[mangaSplitArray[i]].entries[j].media.source, + meanScore: myQuery[mangaSplitArray[i]].entries[j].media.meanScore, + mediaListEntry: + myQuery[mangaSplitArray[i]].entries[j].media.mediaListEntry, + progress: + myQuery[mangaSplitArray[i]].entries[j].media.mediaListEntry + .progress, + progressVolumes: + myQuery[mangaSplitArray[i]].entries[j].media.mediaListEntry + .progressVolumes, + score: + myQuery[mangaSplitArray[i]].entries[j].media.mediaListEntry.score, + notes: + myQuery[mangaSplitArray[i]].entries[j].media.mediaListEntry.notes, + startedAt: + myQuery[mangaSplitArray[i]].entries[j].media.mediaListEntry + .startedAt, + completedAt: + myQuery[mangaSplitArray[i]].entries[j].media.mediaListEntry + .completedAt, + repeat: + myQuery[mangaSplitArray[i]].entries[j].media.mediaListEntry.repeat, + trailer: myQuery[mangaSplitArray[i]].entries[j].media.trailer, + nextAiringEpisode: + myQuery[mangaSplitArray[i]].entries[j].media.nextAiringEpisode, + location: 'mangaCompleted', + key: + myQuery[mangaSplitArray[i]].entries[j].media.title.romaji + + myQuery[mangaSplitArray[i]].entries[j].media.id, + }); + } + } + return accumulator; + } + + return []; +} + +export function getListForCompletedNovels( + myQuery: any, + mangaCompletedIndex: any, + mangaSplitCompletedListFlag: Boolean, + mangaSplitArray: any, +) { + console.log(mangaCompletedIndex); + console.log(mangaSplitCompletedListFlag); + console.log(mangaSplitArray); + if (mangaCompletedIndex !== null && mangaSplitCompletedListFlag === false) { + return myQuery[mangaCompletedIndex].entries.map( + (entry: any, index: any) => ({ + id: entry.media.id, + idMal: entry.media.idMal, + private: entry.private, + titleRomaji: entry.media.title.romaji, + titleEnglish: entry.media.title.english, + titleNative: entry.media.title.native, + synonyms: entry.media.synonyms, + season: entry.media.season, + seasonYear: entry.media.seasonYear, + episodes: entry.media.episodes, + chapters: entry.media.chapters, + volumes: entry.media.volumes, + type: entry.media.type, + format: entry.media.format, + image: entry.media.coverImage.large, + imageMedium: entry.media.coverImage.medium, + imageExtraLarge: entry.media.coverImage.extraLarge, + bannerImage: entry.media.bannerImage, + startYear: entry.media.startDate.year, + startMonth: entry.media.startDate.month, + startDay: entry.media.startDate.day, + description: entry.media.description, + genres: entry.media.genres, + tags: entry.media.tags, + status: entry.media.status, + siteUrl: entry.media.siteUrl, + duration: entry.media.duration, + averageScore: entry.media.averageScore, + popularity: entry.media.popularity, + studios: entry.media.studios.edges, + mainStudioIndex: entry.media.studios.edges + .map((e: any) => { + return e.isMain; + }) + .indexOf(true), + source: entry.media.source, + meanScore: entry.media.meanScore, + mediaListEntry: entry.media.mediaListEntry, + progress: entry.media.mediaListEntry.progress, + progressVolumes: entry.media.mediaListEntry.progressVolumes, + score: entry.media.mediaListEntry.score, + notes: entry.media.mediaListEntry.notes, + startedAt: entry.media.mediaListEntry.startedAt, + completedAt: entry.media.mediaListEntry.completedAt, + repeat: entry.media.mediaListEntry.repeat, + trailer: entry.media.trailer, + nextAiringEpisode: entry.media.nextAiringEpisode, + location: 'mangaCompleted', + key: entry.media.title.romaji + entry.media.id, + }), + ); + } + + const accumulator: any = []; + if (mangaCompletedIndex !== null && mangaSplitCompletedListFlag === true) { + // eslint-disable-next-line no-plusplus + for (let i = 0; i < mangaSplitArray.length; i++) { + // eslint-disable-next-line no-plusplus + for (let j = 0; j < myQuery[mangaSplitArray[i]].entries.length; j++) { + accumulator.push({ + id: myQuery[mangaSplitArray[i]].entries[j].media.id, + idMal: myQuery[mangaSplitArray[i]].entries[j].media.idMal, + private: myQuery[mangaSplitArray[i]].entries[j].private, + titleRomaji: + myQuery[mangaSplitArray[i]].entries[j].media.title.romaji, + titleEnglish: + myQuery[mangaSplitArray[i]].entries[j].media.title.english, + titleNative: + myQuery[mangaSplitArray[i]].entries[j].media.title.native, + synonyms: myQuery[mangaSplitArray[i]].entries[j].media.synonyms, + season: myQuery[mangaSplitArray[i]].entries[j].media.season, + seasonYear: myQuery[mangaSplitArray[i]].entries[j].media.seasonYear, + episodes: myQuery[mangaSplitArray[i]].entries[j].media.episodes, + chapters: myQuery[mangaSplitArray[i]].entries[j].media.chapters, + volumes: myQuery[mangaSplitArray[i]].entries[j].media.volumes, + type: myQuery[mangaSplitArray[i]].entries[j].media.type, + format: myQuery[mangaSplitArray[i]].entries[j].media.format, + image: myQuery[mangaSplitArray[i]].entries[j].media.coverImage.large, + imageMedium: + myQuery[mangaSplitArray[i]].entries[j].media.coverImage.medium, + imageExtraLarge: + myQuery[mangaSplitArray[i]].entries[j].media.coverImage.extraLarge, + bannerImage: myQuery[mangaSplitArray[i]].entries[j].media.bannerImage, + startYear: + myQuery[mangaSplitArray[i]].entries[j].media.startDate.year, + startMonth: + myQuery[mangaSplitArray[i]].entries[j].media.startDate.month, + startDay: myQuery[mangaSplitArray[i]].entries[j].media.startDate.day, + description: myQuery[mangaSplitArray[i]].entries[j].media.description, + genres: myQuery[mangaSplitArray[i]].entries[j].media.genres, + tags: myQuery[mangaSplitArray[i]].entries[j].media.tags, + status: myQuery[mangaSplitArray[i]].entries[j].media.status, + siteUrl: myQuery[mangaSplitArray[i]].entries[j].media.siteUrl, + duration: myQuery[mangaSplitArray[i]].entries[j].media.duration, + averageScore: + myQuery[mangaSplitArray[i]].entries[j].media.averageScore, + popularity: myQuery[mangaSplitArray[i]].entries[j].media.popularity, + studios: myQuery[mangaSplitArray[i]].entries[j].media.studios.edges, + mainStudioIndex: myQuery[mangaSplitArray[i]].entries[ + j + ].media.studios.edges + .map((e: any) => { + return e.isMain; + }) + .indexOf(true), + source: myQuery[mangaSplitArray[i]].entries[j].media.source, + meanScore: myQuery[mangaSplitArray[i]].entries[j].media.meanScore, + mediaListEntry: + myQuery[mangaSplitArray[i]].entries[j].media.mediaListEntry, + progress: + myQuery[mangaSplitArray[i]].entries[j].media.mediaListEntry + .progress, + progressVolumes: + myQuery[mangaSplitArray[i]].entries[j].media.mediaListEntry + .progressVolumes, + score: + myQuery[mangaSplitArray[i]].entries[j].media.mediaListEntry.score, + notes: + myQuery[mangaSplitArray[i]].entries[j].media.mediaListEntry.notes, + startedAt: + myQuery[mangaSplitArray[i]].entries[j].media.mediaListEntry + .startedAt, + completedAt: + myQuery[mangaSplitArray[i]].entries[j].media.mediaListEntry + .completedAt, + repeat: + myQuery[mangaSplitArray[i]].entries[j].media.mediaListEntry.repeat, + trailer: myQuery[mangaSplitArray[i]].entries[j].media.trailer, + nextAiringEpisode: + myQuery[mangaSplitArray[i]].entries[j].media.nextAiringEpisode, + location: 'mangaCompleted', + key: + myQuery[mangaSplitArray[i]].entries[j].media.title.romaji + + myQuery[mangaSplitArray[i]].entries[j].media.id, + }); + } + } + return accumulator; + } + + return []; +} diff --git a/src/renderer/functions/MainMediaListFunctions.tsx b/src/renderer/functions/MainMediaListFunctions.tsx index 6841024..12bfc86 100644 --- a/src/renderer/functions/MainMediaListFunctions.tsx +++ b/src/renderer/functions/MainMediaListFunctions.tsx @@ -1,5 +1,9 @@ import { useQuery, useQueryClient } from '@tanstack/react-query'; import Axios from 'axios'; +import { + getListForCompletedAnime, + getListForCompletedManga, +} from './CheckForListFlags'; export const useMainMediaList = (myUserName: string, myToken: string) => useQuery({ @@ -144,6 +148,8 @@ export const useMainMediaList = (myUserName: string, myToken: string) => let animeOnHoldIndex = null; let animeDroppedIndex = null; let animePlanToWatchIndex = null; + let animeSplitCompletedListFlag = false; + const animeSplitArray = []; // sets the indexes // eslint-disable-next-line no-plusplus @@ -153,6 +159,14 @@ export const useMainMediaList = (myUserName: string, myToken: string) => myQuery[i].isCustomList === false ) { animeWatchingIndex = i; + } else if ( + myQuery[i].status === 'COMPLETED' && + myQuery[i].isCustomList === false && + myQuery[i].isSplitCompletedList === true + ) { + animeCompletedIndex = i; + animeSplitCompletedListFlag = true; + animeSplitArray.push(i); } else if ( myQuery[i].status === 'COMPLETED' && myQuery[i].isCustomList === false @@ -290,6 +304,14 @@ export const useMainMediaList = (myUserName: string, myToken: string) => headers, ).then((res) => res.data.data.MediaListCollection.lists); + const completedAnimeResult = getListForCompletedAnime( + myQuery, + animeCompletedIndex, + animeSplitCompletedListFlag, + animeSplitArray, + ); + + console.log(completedAnimeResult); const myObject: any = { anime: { animeWatching: @@ -348,62 +370,7 @@ export const useMainMediaList = (myUserName: string, myToken: string) => }), ) : [], - animeCompleted: - animeCompletedIndex !== null - ? await myQuery[animeCompletedIndex].entries.map( - (entry: any, index: any) => ({ - id: entry.media.id, - idMal: entry.media.idMal, - private: entry.private, - titleRomaji: entry.media.title.romaji, - titleEnglish: entry.media.title.english, - titleNative: entry.media.title.native, - synonyms: entry.media.synonyms, - season: entry.media.season, - seasonYear: entry.media.seasonYear, - episodes: entry.media.episodes, - chapters: entry.media.chapters, - volumes: entry.media.volumes, - type: entry.media.type, - format: entry.media.format, - image: entry.media.coverImage.large, - imageMedium: entry.media.coverImage.medium, - imageExtraLarge: entry.media.coverImage.extraLarge, - bannerImage: entry.media.bannerImage, - startYear: entry.media.startDate.year, - startMonth: entry.media.startDate.month, - startDay: entry.media.startDate.day, - description: entry.media.description, - genres: entry.media.genres, - tags: entry.media.tags, - status: entry.media.status, - siteUrl: entry.media.siteUrl, - duration: entry.media.duration, - averageScore: entry.media.averageScore, - popularity: entry.media.popularity, - studios: entry.media.studios.edges, - mainStudioIndex: entry.media.studios.edges - .map((e: any) => { - return e.isMain; - }) - .indexOf(true), - source: entry.media.source, - meanScore: entry.media.meanScore, - mediaListEntry: entry.media.mediaListEntry, - progress: entry.media.mediaListEntry.progress, - progressVolumes: entry.media.mediaListEntry.progressVolumes, - score: entry.media.mediaListEntry.score, - notes: entry.media.mediaListEntry.notes, - startedAt: entry.media.mediaListEntry.startedAt, - completedAt: entry.media.mediaListEntry.completedAt, - repeat: entry.media.mediaListEntry.repeat, - trailer: entry.media.trailer, - nextAiringEpisode: entry.media.nextAiringEpisode, - location: 'animeCompleted', - key: entry.media.title.romaji + entry.media.id, - }), - ) - : [], + animeCompleted: completedAnimeResult, animeOnHold: animeOnHoldIndex !== null ? await myQuery[animeOnHoldIndex].entries.map( @@ -595,9 +562,12 @@ export const useMainMediaList = (myUserName: string, myToken: string) => console.log(myQueryManga); let mangaQueryReadingIndex = null; let mangaQueryCompletedIndex = null; + let lightNovelQueryCompletedIndex = null; let mangaQueryPlanToReadIndex = null; let mangaQueryDroppedIndex = null; let mangaQueryOnHoldIndex = null; + let mangaSplitCompletedListFlag = false; + const mangaSplitArray = []; // eslint-disable-next-line no-plusplus for (let i = 0; i < myQueryManga.length; i++) { @@ -606,11 +576,30 @@ export const useMainMediaList = (myUserName: string, myToken: string) => myQueryManga[i].isCustomList === false ) { mangaQueryReadingIndex = i; + } else if ( + myQueryManga[i].status === 'COMPLETED' && + myQueryManga[i].isCustomList === false && + myQueryManga[i].isSplitCompletedList === true && + myQueryManga[i].name.includes('Manga') + ) { + mangaQueryCompletedIndex = i; + mangaSplitCompletedListFlag = true; + mangaSplitArray.push(i); + } else if ( + myQueryManga[i].status === 'COMPLETED' && + myQueryManga[i].isCustomList === false && + myQueryManga[i].isSplitCompletedList === true && + myQueryManga[i].name.includes('Novel') + ) { + lightNovelQueryCompletedIndex = i; + mangaSplitCompletedListFlag = true; + mangaSplitArray.push(i); } else if ( myQueryManga[i].status === 'COMPLETED' && myQueryManga[i].isCustomList === false ) { mangaQueryCompletedIndex = i; + lightNovelQueryCompletedIndex = i; } else if ( myQueryManga[i].status === 'PLANNING' && myQueryManga[i].isCustomList === false @@ -628,6 +617,15 @@ export const useMainMediaList = (myUserName: string, myToken: string) => mangaQueryDroppedIndex = i; } } + + const completedMangaResult = getListForCompletedManga( + myQueryManga, + mangaQueryCompletedIndex, + mangaSplitCompletedListFlag, + mangaSplitArray, + ); + + console.log(completedMangaResult); // eslint-disable-next-line no-plusplus for (let i = 0; i < myQueryManga.length; i++) { // lists @@ -706,7 +704,7 @@ export const useMainMediaList = (myUserName: string, myToken: string) => myQueryManga[i].entries[j].media.id, }); } - if (i === mangaQueryCompletedIndex) { + if (i === lightNovelQueryCompletedIndex) { myObject.lightNovels.lightNovelsCompleted = myObject.lightNovels.lightNovelsCompleted.concat({ id: myQueryManga[i].entries[j].media.id,