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: `{ 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; };