Some checks failed
Deploy / Deploy (push) Has been cancelled
also removed any references to Anify
23 lines
716 B
TypeScript
23 lines
716 B
TypeScript
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));
|
|
}
|
|
}
|