From f056a1e19470967198b1dab61cf6133047f07afd Mon Sep 17 00:00:00 2001 From: Fuwn Date: Fri, 15 Dec 2023 23:54:53 -0800 Subject: feat(notifications): refresh token --- src/lib/AniList/notifications.ts | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'src/lib/AniList/notifications.ts') diff --git a/src/lib/AniList/notifications.ts b/src/lib/AniList/notifications.ts index 4fdb9cb5..bebf1b42 100644 --- a/src/lib/AniList/notifications.ts +++ b/src/lib/AniList/notifications.ts @@ -30,7 +30,7 @@ export interface Notification { | 'THREAD_LIKE'; } -export const notifications = async (accessToken: string): Promise => { +export const notifications = async (accessToken: string): Promise => { const activityNotification = (type: string, extend = '') => `... on ${type} { id user { name avatar { large } } context createdAt type ${extend} }`; @@ -45,18 +45,16 @@ export const notifications = async (accessToken: string): Promise `${activityNotification(type, `thread { title id }`)}`; - - return ( - await ( - await fetch('https://graphql.anilist.co', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${accessToken}`, - Accept: 'application/json' - }, - body: JSON.stringify({ - query: `{ Page(page: 1, perPage: 50) { notifications { + const data = await ( + await fetch('https://graphql.anilist.co', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${accessToken}`, + Accept: 'application/json' + }, + body: JSON.stringify({ + query: `{ Page(page: 1, perPage: 50) { notifications { ${activityNotification('FollowingNotification')} ${activityNotification('ActivityMessageNotification')} ${richActivityNotification('ActivityMentionNotification')} @@ -70,8 +68,11 @@ export const notifications = async (accessToken: string): Promise