blob: 995ff6eb14cfd36b6d1f03186adff3c745f03f77 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
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 }
} }`
})
})
).json();
const date = new Date(0);
date.setUTCSeconds(activityHistory['data']['Activity']['createdAt']);
return date;
};
|