implement caching for TeslaCam directory scan and add refresh endpoint

This commit is contained in:
zwitschi committed 2026-07-24 12:58:58 +02:00
1 parent a4202afe30
commit 829c28ca69
3 files changed
+57 -6

No files matched your search

+18 -5
View File
@@ -1029,18 +1029,31 @@
}
});
// Auto-play next clip when video finishes
// Auto-play next clip of the same camera when video finishes
player.addEventListener("ended", function () {
const list = getFiltered();
const i = list.findIndex(function (c) {
if (!current) return;
// Build a list of clips for the SAME camera, sorted like the sidebar
const sameCam = clips
.filter(function (c) {
return c.cam === current.cam;
})
.sort(function (a, b) {
if (sortMode === "name")
return a.filename.localeCompare(b.filename);
const da = tsToDate(a.timestamp),
db = tsToDate(b.timestamp);
const ta = da ? da.getTime() : 0,
tb = db ? db.getTime() : 0;
return sortMode === "oldest" ? ta - tb : tb - ta;
});
const i = sameCam.findIndex(function (c) {
return (
current &&
c.cam === current.cam &&
c.timestamp === current.timestamp &&
c.filename === current.filename
);
});
if (i > -1 && list[i + 1]) playClip(list[i + 1]);
if (i > -1 && sameCam[i + 1]) playClip(sameCam[i + 1]);
});
render();