Skip to content

Commit

Permalink
reduce watching interval time
Browse files Browse the repository at this point in the history
  • Loading branch information
iswilljr committed Dec 21, 2024
1 parent decb291 commit 54b9a83
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/pages/api/watching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { z } from 'astro:schema'
type WatchingData = typeof Watching.$inferSelect
type InputData = z.infer<typeof InputDataSchema>

const WATCHING_TIME_IN_MINUTES = 5

const InputDataSchema = z.object({
episode: z.number(),
mediaId: z.number(),
Expand Down Expand Up @@ -91,7 +93,9 @@ async function getWatchingDetails(

let details = watching?.details
let runtime = watching?.runtime ?? 0
let watchedTime = isNew ? 1 : watching.watchedTime + 1
let watchedTime = isNew
? WATCHING_TIME_IN_MINUTES
: watching.watchedTime + WATCHING_TIME_IN_MINUTES

if (isMovie && isNew) {
details = await getMovie(input.mediaId)
Expand Down
2 changes: 1 addition & 1 deletion src/pages/play/[media]/[mediaId]/[mediaTitle]/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ Astro.response.headers.set(
window.clear()
}

window.watchingTimeout = setInterval(handler, 1000 * 60)
window.watchingTimeout = setInterval(handler, 1000 * 60 * 5)
document.removeEventListener('astro:after-swap', window.clear)
document.addEventListener('astro:after-swap', window.clear)
</script>

0 comments on commit 54b9a83

Please sign in to comment.