mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
feat(board stats): remember hide/show choice per subplebbit
This commit is contained in:
@@ -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;
|
||||
Reference in New Issue
Block a user