Delay manual snapshot refresh
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
const SNAPSHOT_REFRESH_DELAY_MS = 2000;
|
||||||
|
|
||||||
function formatRemaining(totalSeconds) {
|
function formatRemaining(totalSeconds) {
|
||||||
const seconds = Math.max(0, Math.ceil(totalSeconds));
|
const seconds = Math.max(0, Math.ceil(totalSeconds));
|
||||||
const minutes = Math.floor(seconds / 60);
|
const minutes = Math.floor(seconds / 60);
|
||||||
@@ -122,7 +124,9 @@ function refreshSnapshot(button) {
|
|||||||
button.setAttribute("aria-busy", "true");
|
button.setAttribute("aria-busy", "true");
|
||||||
image.addEventListener("load", cleanup, { once: true });
|
image.addEventListener("load", cleanup, { once: true });
|
||||||
image.addEventListener("error", 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) => {
|
document.addEventListener("click", (event) => {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import unittest
|
import unittest
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from frigate_camera_control_bridge.ui import camera_stream_url, render_page
|
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.assertIn("<h2>Camera Friendly</h2>", html)
|
||||||
self.assertNotIn("<h2>camera_key</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__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
Reference in New Issue
Block a user