Delay manual snapshot refresh

This commit is contained in:
2026-08-03 01:40:15 +02:00
parent 6b2bc3853a
commit 15ec93f82e
2 changed files with 12 additions and 1 deletions
+5 -1
View File
@@ -1,3 +1,5 @@
const SNAPSHOT_REFRESH_DELAY_MS = 2000;
function formatRemaining(totalSeconds) {
const seconds = Math.max(0, Math.ceil(totalSeconds));
const minutes = Math.floor(seconds / 60);
@@ -122,7 +124,9 @@ function refreshSnapshot(button) {
button.setAttribute("aria-busy", "true");
image.addEventListener("load", cleanup, { once: true });
image.addEventListener("error", cleanup, { once: true });
image.src = url.toString();
window.setTimeout(() => {
image.src = url.toString();
}, SNAPSHOT_REFRESH_DELAY_MS);
}
document.addEventListener("click", (event) => {
+7
View File
@@ -1,4 +1,5 @@
import unittest
from pathlib import Path
from frigate_camera_control_bridge.ui import camera_stream_url, render_page
@@ -114,6 +115,12 @@ class UiRenderTest(unittest.TestCase):
self.assertIn("<h2>Camera Friendly</h2>", html)
self.assertNotIn("<h2>camera_key</h2>", html)
def test_manual_snapshot_refresh_waits_before_fetch(self):
script = Path("frigate_camera_control_bridge/static/app.js").read_text(encoding="utf-8")
self.assertIn("SNAPSHOT_REFRESH_DELAY_MS = 2000", script)
self.assertIn("window.setTimeout", script)
if __name__ == "__main__":
unittest.main()