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:
2026-05-24 04:57:13 -06:00
parent 5dda46cb87
commit d5e80ec380
13 changed files with 333 additions and 56 deletions

View 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;
}