Finish interrupted features: tab prefetch, pet viewport, and home logo.
Add shared quiz/habits tab cache with nav hover prefetch and AppDataPrefetcher, make the pet screen fill and center the viewport, and point the HaBit logo to /.
This commit is contained in:
36
components/layout/app-data-prefetcher.tsx
Normal file
36
components/layout/app-data-prefetcher.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
|
||||
import { HABIT_PET_DATA_UPDATED_EVENT } from "@/lib/app-events";
|
||||
import {
|
||||
invalidateAppTabDataCache,
|
||||
prefetchAppTabData,
|
||||
} from "@/lib/app-tab-data-cache";
|
||||
|
||||
type AppDataPrefetcherProps = {
|
||||
enabled: boolean;
|
||||
};
|
||||
|
||||
export function AppDataPrefetcher({ enabled }: AppDataPrefetcherProps) {
|
||||
useEffect(() => {
|
||||
if (!enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
void prefetchAppTabData();
|
||||
|
||||
const handleDataUpdated = () => {
|
||||
invalidateAppTabDataCache();
|
||||
void prefetchAppTabData({ force: true });
|
||||
};
|
||||
|
||||
window.addEventListener(HABIT_PET_DATA_UPDATED_EVENT, handleDataUpdated);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener(HABIT_PET_DATA_UPDATED_EVENT, handleDataUpdated);
|
||||
};
|
||||
}, [enabled]);
|
||||
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user