diff options
| author | Fuwn <[email protected]> | 2023-09-06 03:54:07 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-09-06 03:54:07 -0700 |
| commit | fe9a191a008b2f5e4d8fece1b36d6bd3b1f068f2 (patch) | |
| tree | 51f1c5c87bb3e77c83fed1d7cba76fe375877a6e /src/lib | |
| parent | refactor(settings): rename setting (diff) | |
| download | due.moe-fe9a191a008b2f5e4d8fece1b36d6bd3b1f068f2.tar.xz due.moe-fe9a191a008b2f5e4d8fece1b36d6bd3b1f068f2.zip | |
fix(activity): last activity check
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/AniList/activity.ts | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/lib/AniList/activity.ts b/src/lib/AniList/activity.ts index 995ff6eb..aa22a590 100644 --- a/src/lib/AniList/activity.ts +++ b/src/lib/AniList/activity.ts @@ -1,23 +1,25 @@ import type { UserIdentity } from './identity'; export const lastActivityDate = async (userIdentity: UserIdentity): Promise<Date> => { - const activityHistory = await ( - await fetch('https://graphql.anilist.co', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - Accept: 'application/json' - }, - body: JSON.stringify({ - query: `{ Activity(userId: ${userIdentity.id}, type: MEDIA_LIST, sort: ID_DESC) { - __typename ... on ListActivity { createdAt } + const activityHistory = ( + await ( + await fetch('https://graphql.anilist.co', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Accept: 'application/json' + }, + body: JSON.stringify({ + query: `{ User(id: ${userIdentity.id}) { + stats { activityHistory { date } } } }` + }) }) - }) - ).json(); + ).json() + )['data']['User']['stats']['activityHistory']; const date = new Date(0); - date.setUTCSeconds(activityHistory['data']['Activity']['createdAt']); + date.setUTCSeconds(activityHistory[activityHistory.length - 1]['date']); return date; }; |