diff options
author | metamuffin <metamuffin@disroot.org> | 2024-01-26 01:05:26 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-01-26 01:05:26 +0100 |
commit | c58099970f53fbd94c36193f77b06c5eb1f329b1 (patch) | |
tree | 4ab95fda3b6cefe3cc7c7b0ac29ebd19858ef882 | |
parent | 04f44fdc7e5d155d73028ec721308e46a5b4b669 (diff) | |
download | jellything-c58099970f53fbd94c36193f77b06c5eb1f329b1.tar jellything-c58099970f53fbd94c36193f77b06c5eb1f329b1.tar.bz2 jellything-c58099970f53fbd94c36193f77b06c5eb1f329b1.tar.zst |
player sends less watched state packets
-rw-r--r-- | web/script/player/mod.ts | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/web/script/player/mod.ts b/web/script/player/mod.ts index 3294540..fb075d7 100644 --- a/web/script/player/mod.ts +++ b/web/script/player/mod.ts @@ -223,6 +223,7 @@ function initialize_player(el: HTMLElement, node_id: string) { send_player_progress(node_id, player) } +let sent_watched = false; function send_player_progress(node_id: string, player: Player) { let t = 0; setInterval(() => { @@ -233,7 +234,10 @@ function send_player_progress(node_id: string, player: Player) { const end = nt > player.duration.value - 5 * 60 if (!start) fetch(`/n/${encodeURIComponent(node_id)}/progress?t=${nt}`, { method: "POST" }) - if (end) fetch(`/n/${encodeURIComponent(node_id)}/watched?state=watched`, { method: "POST" }) + if (end && !sent_watched) { + fetch(`/n/${encodeURIComponent(node_id)}/watched?state=watched`, { method: "POST" }) + sent_watched = true; + } } }, 10000) } |