Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions frontend/src/ts/kiosk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,17 @@ function addEventListeners(): void {
htmx.addClass(offlineSVG, "offline");
}
});

// Slideshow polling control. Fires after every AJAX request.
// Only (re)start polling when a new asset has been loaded
htmx.on("htmx:afterRequest", (e: HTMXEvent) => {
const path = e.detail?.pathInfo?.requestPath || "";

// Only restart polling for asset endpoints (new slide)
if (path.startsWith("/asset/")) {
startPolling();
}
});

htmx.on("htmx:timeout", (e: HTMXEvent) => {
let currentTimeout = timeouts[e.detail.pathInfo.requestPath];
Expand Down Expand Up @@ -416,6 +427,13 @@ async function cleanupFrames(): Promise<void> {
* @throws {Error} If request lock is already set
*/
function setRequestLock(e: HTMXEvent): void {
const path = e.detail?.pathInfo?.requestPath || "";

// Only lock and pause polling for asset requests (new slide)
if (!path.startsWith("/asset/")) {
return;
}

if (requestInFlight) {
e.preventDefault();
return;
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/ts/polling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ class PollingController {
* Starts the polling process
*/
startPolling = () => {
console.debug("[DEBUG] startPolling() called", {
pollInterval: this.pollInterval,
timestamp: performance.now(),
});

this.progressBarElement?.classList.remove("progress--bar-paused");
this.menuElement?.classList.add("navigation-hidden");
this.lastPollTime = performance.now();
Expand Down
1 change: 0 additions & 1 deletion internal/templates/views/views_home.templ
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ templ Home(viewData common.ViewData, secret string) {
hx-include=".kiosk-history--entry"
hx-trigger={ triggers(viewData.DisableNavigation) }
hx-on::before-send="kiosk.setRequestLock(event)"
hx-on::after-request="kiosk.startPolling()"
hx-on::after-swap="kiosk.releaseRequestLock(), kiosk.cleanupFrames()"
>
@partials.Spinner()
Expand Down