blob: aa22a5907d3cb40840ab5c82112041d0586aacdc (
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
24
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: `{ User(id: ${userIdentity.id}) {
stats { activityHistory { date } }
} }`
})
})
).json()
)['data']['User']['stats']['activityHistory'];
const date = new Date(0);
date.setUTCSeconds(activityHistory[activityHistory.length - 1]['date']);
return date;
};
|