diff options
| author | Fuwn <[email protected]> | 2025-12-15 02:46:17 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-12-15 02:46:17 -0800 |
| commit | 87d3569e8da3b69e574e17d27e5dd0fb3dcfdc67 (patch) | |
| tree | f3bc10147cbab6dc855c5e4faa483645f34a2918 /src/lib/Data | |
| parent | fix(api:birthdays): Update HTML parser for primary source (diff) | |
| download | due.moe-87d3569e8da3b69e574e17d27e5dd0fb3dcfdc67.tar.xz due.moe-87d3569e8da3b69e574e17d27e5dd0fb3dcfdc67.zip | |
feat(Wrapped): Add detailed activity fetcher toggle
Diffstat (limited to 'src/lib/Data')
| -rw-r--r-- | src/lib/Data/AniList/activity.ts | 5 | ||||
| -rw-r--r-- | src/lib/Data/AniList/wrapped.ts | 11 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/lib/Data/AniList/activity.ts b/src/lib/Data/AniList/activity.ts index 2c16fb1f..afe3cef3 100644 --- a/src/lib/Data/AniList/activity.ts +++ b/src/lib/Data/AniList/activity.ts @@ -184,7 +184,8 @@ const activitiesPage = async ( export const fullActivityHistory = async ( anilistAuthorisation: AniListAuthorisation, userIdentity: UserIdentity, - year = new Date().getFullYear() + year = new Date().getFullYear(), + disableLoopingActivityCounter = false ): Promise<ActivityHistoryEntry[]> => { const activities = []; let page = 1; @@ -203,6 +204,8 @@ export const fullActivityHistory = async ( for (const activity of currentPage.data.Page.activities) activities.push(activity); while (currentPage['data']['Page']['pageInfo']['hasNextPage']) { + if (disableLoopingActivityCounter) break; + for (const activity of currentPage.data.Page.activities) activities.push(activity); page += 1; diff --git a/src/lib/Data/AniList/wrapped.ts b/src/lib/Data/AniList/wrapped.ts index 62aff010..4ca9f772 100644 --- a/src/lib/Data/AniList/wrapped.ts +++ b/src/lib/Data/AniList/wrapped.ts @@ -48,7 +48,8 @@ export interface Wrapped { const profileActivities = async ( user: AniListAuthorisation, identity: UserIdentity, - date = new Date() + date = new Date(), + disableLoopingActivityCounter = false ) => { const now = date.getTime(); const get = async (page: number) => @@ -91,6 +92,8 @@ const profileActivities = async ( pages.push(response['data']['Page']['activities']); while (response['data']['Page']['pageInfo']['hasNextPage']) { + if (disableLoopingActivityCounter) break; + page += 1; response = await get(page); @@ -121,7 +124,8 @@ export const wrapped = async ( anilistAuthorisation: AniListAuthorisation | undefined, identity: UserIdentity, year = new Date().getFullYear(), - skipActivities = false + skipActivities = false, + disableLoopingActivityCounter = false ): Promise<Wrapped> => { const headers: { [key: string]: string } = { 'Content-Type': 'application/json', @@ -165,7 +169,8 @@ export const wrapped = async ( const { statusCount, messageCount } = await profileActivities( anilistAuthorisation, identity, - new Date(year, 11, 31) + new Date(year, 11, 31), + disableLoopingActivityCounter ); statusCountActivities = statusCount; |