Skip to content

Add object detection, tracking, mobile notifications, and search to any security camera.

dont fetch twice

roryclear2488f03e00ab
diff --git a/clearcam/player.html b/clearcam/player.html
index 4957a1d..4c336f5 100644
--- a/clearcam/player.html
+++ b/clearcam/player.html
@@ -348,11 +348,15 @@
return `${year}-${month}-${day}`;
}
+ let isFetchingSegments = false;
async function fetchSegments() {
+ if (isFetchingSegments) return;
+ isFetchingSegments = true;
+
try {
const startParam = segments.length;
-
const response = await fetch(`/get-segments?date=${currentDate}&start=${startParam}`);
+
if (response.ok) {
const newSegments = await response.json();
if (Array.isArray(newSegments)) {
@@ -392,9 +396,12 @@
}
} catch (error) {
console.error('Failed to fetch segments:', error);
+ } finally {
+ isFetchingSegments = false;
}
}
+
function formatTime(seconds) {
const hours = Math.floor(seconds / 3600).toString().padStart(2, '0');
const minutes = Math.floor((seconds % 3600) / 60).toString().padStart(2, '0');