also removed any references to Anify
This commit is contained in:
22
src/services/watch-status/index.ts
Normal file
22
src/services/watch-status/index.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { maybeScheduleNextAiringEpisode } from "~/libs/maybeScheduleNextAiringEpisode";
|
||||
import { buildNewEpisodeTaskId } from "~/libs/tasks/id";
|
||||
import { removeTask } from "~/libs/tasks/removeTask";
|
||||
import { setWatchStatus } from "~/models/watchStatus";
|
||||
import { WatchStatus } from "~/types/title/watchStatus";
|
||||
|
||||
export async function updateWatchStatus(
|
||||
deviceId: string,
|
||||
titleId: number,
|
||||
watchStatus: WatchStatus | null,
|
||||
) {
|
||||
const { wasAdded, wasDeleted } = await setWatchStatus(
|
||||
deviceId,
|
||||
Number(titleId),
|
||||
watchStatus,
|
||||
);
|
||||
if (wasAdded) {
|
||||
await maybeScheduleNextAiringEpisode(titleId);
|
||||
} else if (wasDeleted) {
|
||||
await removeTask("NEW_EPISODE", buildNewEpisodeTaskId(titleId));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user