Skip to content

Commit d34486d

Browse files
committed
Refactor code structure for improved readability and maintainability
1 parent 4d5c5be commit d34486d

3 files changed

Lines changed: 25 additions & 7 deletions

File tree

pi-node/kiosk.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ exec chromium-browser \
2323
--noerrdialogs \
2424
--disable-infobars \
2525
--kiosk \
26-
--incognito \
2726
--disable-translate \
2827
--disable-features=TranslateUI \
2928
--disable-session-crashed-bubble \
@@ -33,4 +32,7 @@ exec chromium-browser \
3332
--no-first-run \
3433
--start-fullscreen \
3534
--window-size=1920,1080 \
35+
--enable-features=NetworkService,NetworkServiceInProcess \
36+
--disable-sync \
37+
--no-default-browser-check \
3638
"$DISPLAY_URL"

server/src/components/display/floor-display.tsx

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@ export function FloorDisplay({ floor, announcements: initialAnnouncements }: Pro
5858
// Fetch latest data without page reload
5959
const refreshData = useCallback(async () => {
6060
try {
61+
// Cache-bust with timestamp to ensure fresh data
62+
const cacheBust = Date.now();
6163
const [floorRes, annRes] = await Promise.all([
62-
fetch(`/api/floors/${floor.id}`),
63-
fetch(`/api/announcements?floorId=${floor.id}&active=true`),
64+
fetch(`/api/floors/${floor.id}?t=${cacheBust}`, { cache: "no-store" }),
65+
fetch(`/api/announcements?floorId=${floor.id}&active=true&t=${cacheBust}`, { cache: "no-store" }),
6466
]);
6567
if (floorRes.ok) {
6668
const data = await floorRes.json();
@@ -79,8 +81,9 @@ export function FloorDisplay({ floor, announcements: initialAnnouncements }: Pro
7981
);
8082
}
8183
setLastUpdate(Date.now());
84+
console.log("[display] data refreshed successfully");
8285
} catch (e) {
83-
console.warn("[display] refresh failed:", e);
86+
console.error("[display] refresh failed:", e);
8487
}
8588
}, [floor.id]);
8689

@@ -137,15 +140,28 @@ export function FloorDisplay({ floor, announcements: initialAnnouncements }: Pro
137140

138141
// Aggressive fallback: refresh every 10s if no recent update
139142
useEffect(() => {
140-
const timer = setInterval(() => {
143+
const checkTimer = setInterval(() => {
141144
const timeSinceLastUpdate = Date.now() - lastUpdate;
142145
// Refresh if >8 seconds since last successful update
143146
if (timeSinceLastUpdate > 8_000) {
144147
console.log(`[display] fallback refresh (${Math.round(timeSinceLastUpdate / 1000)}s since last update)`);
145148
refreshData();
146149
}
147150
}, 3_000); // Check every 3s (fast and lightweight)
148-
return () => clearInterval(timer);
151+
152+
// Nuclear option: if no update for 2 minutes, hard reload page
153+
const hardReloadTimer = setInterval(() => {
154+
const timeSinceLastUpdate = Date.now() - lastUpdate;
155+
if (timeSinceLastUpdate > 120_000) {
156+
console.warn("[display] NO UPDATE FOR 2 MINUTES - HARD RELOAD PAGE");
157+
window.location.reload();
158+
}
159+
}, 30_000);
160+
161+
return () => {
162+
clearInterval(checkTimer);
163+
clearInterval(hardReloadTimer);
164+
};
149165
}, [refreshData, lastUpdate]);
150166

151167
const now = time.getTime();

server/tsconfig.tsbuildinfo

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)