feat(home stats): load stats progressively

This commit is contained in:
Tommaso Casaburi
2026-06-03 14:47:51 +07:00
parent 84f357cba1
commit d357514397
40 changed files with 420 additions and 181 deletions
@@ -0,0 +1,22 @@
import { create } from 'zustand';
export type HomepageStatsScope = 'directory' | 'all';
const LOCALSTORAGE_KEY = '5chan-homepage-stats-scope';
const readInitialStatsScope = (): HomepageStatsScope => (localStorage.getItem(LOCALSTORAGE_KEY) === 'all' ? 'all' : 'directory');
interface HomepageStatsOptionsStore {
statsScope: HomepageStatsScope;
setStatsScope: (value: HomepageStatsScope) => void;
}
const useHomepageStatsOptionsStore = create<HomepageStatsOptionsStore>((set) => ({
statsScope: readInitialStatsScope(),
setStatsScope: (value) => {
set({ statsScope: value });
localStorage.setItem(LOCALSTORAGE_KEY, value);
},
}));
export default useHomepageStatsOptionsStore;