import type { UserIdentity } from './identity'; export const lastActivityDate = async (userIdentity: UserIdentity): Promise => { 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( Number(activityHistory[activityHistory.length - 1]['date']) * 1000 + new Date().getTimezoneOffset() ); date.setDate(date.getDate() + 1); return date; };