feat(board stats): remember hide/show choice per subplebbit

This commit is contained in:
Tom (plebeius.eth)
2024-08-29 14:37:47 +02:00
parent edaa1a2ae1
commit d482d32467
2 changed files with 35 additions and 7 deletions
@@ -0,0 +1,27 @@
import { create } from 'zustand';
import { persist } from 'zustand/middleware';
interface SubplebbitStatsVisibilityState {
hiddenStats: { [subplebbitAddress: string]: boolean };
toggleVisibility: (subplebbitAddress: string) => void;
}
const useSubplebbitStatsVisibilityStore = create<SubplebbitStatsVisibilityState>()(
persist(
(set) => ({
hiddenStats: {},
toggleVisibility: (subplebbitAddress) =>
set((state) => ({
hiddenStats: {
...state.hiddenStats,
[subplebbitAddress]: !state.hiddenStats[subplebbitAddress],
},
})),
}),
{
name: 'subplebbit-stats-visibility',
},
),
);
export default useSubplebbitStatsVisibilityStore;