Merge remote-tracking branch 'origin/main' into terry-wallet-login

This commit is contained in:
TerryM
2026-06-02 12:08:45 +08:00
15 changed files with 271 additions and 107 deletions

View File

@@ -45,7 +45,15 @@ export function Home() {
const { t, lang } = useI18n();
const lp = useLocalizedPath();
const { hash } = useLocation();
const [cats, setCats] = useState<Category[]>([]);
// Seed from cache on the first render so the categories (and their icons)
// are present immediately when navigating back to the home page, instead of
// flashing empty for a frame before the effect re-applies the cached data.
const [cats, setCats] = useState<Category[]>(() => {
const cached = readJSONCache<Category[]>(
`/api/categories?lang=${encodeURIComponent(langQuery(lang))}`,
);
return cached ? itemsOrEmpty(cached) : [];
});
const [rec, setRec] = useState<PostBackedResource[]>([]);
const [latestPosts, setLatestPosts] = useState<Post[]>([]);
const [popular, setPopular] = useState<PostBackedResource[]>([]);