Add cached dashboard prewarm hints for priority cities
This commit is contained in:
@@ -618,6 +618,25 @@ export function DashboardStoreProvider({
|
||||
void loadCities();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!cities.length) return;
|
||||
if (typeof window === "undefined") return;
|
||||
const schedule = () => dashboardClient.sendPriorityWarmHint();
|
||||
const idleCallback = (window as Window & {
|
||||
requestIdleCallback?: (callback: () => void, options?: { timeout: number }) => number;
|
||||
}).requestIdleCallback;
|
||||
if (typeof idleCallback === "function") {
|
||||
const id = idleCallback(schedule, { timeout: 3000 });
|
||||
return () => {
|
||||
if (typeof window.cancelIdleCallback === "function") {
|
||||
window.cancelIdleCallback(id);
|
||||
}
|
||||
};
|
||||
}
|
||||
const timer = window.setTimeout(schedule, 2000);
|
||||
return () => window.clearTimeout(timer);
|
||||
}, [cities.length]);
|
||||
|
||||
useEffect(() => {
|
||||
void refreshProAccess();
|
||||
}, []);
|
||||
|
||||
Reference in New Issue
Block a user