From b26d22ad9181ed1b418948ea55d98e94a8de34fb Mon Sep 17 00:00:00 2001 From: Rushil Perera Date: Wed, 17 Dec 2025 07:51:19 -0500 Subject: [PATCH] feat: conditionally queue AniList updates and use updated payload --- src/controllers/watch-status/index.ts | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/controllers/watch-status/index.ts b/src/controllers/watch-status/index.ts index f24dbb3..eeb48ad 100644 --- a/src/controllers/watch-status/index.ts +++ b/src/controllers/watch-status/index.ts @@ -87,8 +87,6 @@ app.openapi(route, async (c) => { titleId, isRetrying = false, } = await c.req.json(); - const aniListToken = c.req.header("X-AniList-Token"); - // Check if we should use mock data const { useMockData } = await import("~/libs/useMockData"); if (useMockData()) { @@ -106,16 +104,21 @@ app.openapi(route, async (c) => { } } - await queueTask( - "ANILIST_UPDATES", - { - deviceId, - watchStatus, - titleId, - updateType: AnilistUpdateType.UpdateWatchStatus, - }, - { req: c.req, scheduleConfig: { delay: { minute: 1 } } }, - ); + const aniListToken = c.req.header("X-AniList-Token"); + if (aniListToken) { + await queueTask( + "ANILIST_UPDATES", + { + [AnilistUpdateType.UpdateWatchStatus]: { + aniListToken, + titleId, + watchStatus, + }, + updateType: AnilistUpdateType.UpdateWatchStatus, + }, + { req: c.req, scheduleConfig: { delay: { minute: 1 } } }, + ); + } return c.json(SuccessResponse, { status: 200 }); });