mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
28 lines
728 B
TypeScript
28 lines
728 B
TypeScript
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;
|