- Updated theme resolution logic to utilize a shared inline script for consistent theme application across routes. - Introduced `AppShell` and `ReadyGate` components to manage app readiness and theme synchronization, improving user experience. - Enhanced `GlobalError` and `NotFound` pages with a unified full-screen layout for better accessibility and visual consistency. - Refactored CSS to implement safe area insets for sticky headers and content safety, ensuring proper layout on various devices. - Added unit tests for new functionality and improved existing tests for better coverage and reliability.
30 lines
886 B
TypeScript
30 lines
886 B
TypeScript
/**
|
|
* 60-second interval to refresh duty list when viewing the current month.
|
|
* Replaces state.todayRefreshInterval from webapp/js/main.js.
|
|
*/
|
|
|
|
"use client";
|
|
|
|
import { useEffect, useRef } from "react";
|
|
|
|
const AUTO_REFRESH_INTERVAL_MS = 60000;
|
|
|
|
/**
|
|
* When isCurrentMonth is true, starts a 60-second interval to refresh. Does not call refresh()
|
|
* immediately so the initial load is handled only by useMonthData (avoids duplicate first fetch).
|
|
* When isCurrentMonth becomes false or on unmount, the interval is cleared.
|
|
*/
|
|
export function useAutoRefresh(
|
|
refresh: () => void,
|
|
isCurrentMonth: boolean
|
|
): void {
|
|
const refreshRef = useRef(refresh);
|
|
refreshRef.current = refresh;
|
|
|
|
useEffect(() => {
|
|
if (!isCurrentMonth) return;
|
|
const id = setInterval(() => refreshRef.current(), AUTO_REFRESH_INTERVAL_MS);
|
|
return () => clearInterval(id);
|
|
}, [isCurrentMonth]);
|
|
}
|