pl-fe: use more specific zustand selectors
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -4,28 +4,34 @@ type State = {
|
||||
ref: React.MutableRefObject<HTMLDivElement> | null;
|
||||
statusId: string | null;
|
||||
hovered: boolean;
|
||||
openStatusHoverCard: (ref: React.MutableRefObject<HTMLDivElement>, statusId: string) => void;
|
||||
updateStatusHoverCard: () => void;
|
||||
closeStatusHoverCard: (force?: boolean) => void;
|
||||
actions: {
|
||||
openStatusHoverCard: (ref: React.MutableRefObject<HTMLDivElement>, statusId: string) => void;
|
||||
updateStatusHoverCard: () => void;
|
||||
closeStatusHoverCard: (force?: boolean) => void;
|
||||
};
|
||||
}
|
||||
|
||||
const useStatusHoverCardStore = create<State>((set) => ({
|
||||
ref: null,
|
||||
statusId: null,
|
||||
hovered: false,
|
||||
openStatusHoverCard: (ref, statusId) => set({
|
||||
ref,
|
||||
statusId,
|
||||
}),
|
||||
updateStatusHoverCard: () => set({
|
||||
hovered: true,
|
||||
}),
|
||||
closeStatusHoverCard: (force = false) => set((state) => state.hovered && !force ? {} : {
|
||||
ref: null,
|
||||
statusId: null,
|
||||
hovered: false,
|
||||
}),
|
||||
actions: {
|
||||
openStatusHoverCard: (ref, statusId) => set({
|
||||
ref,
|
||||
statusId,
|
||||
}),
|
||||
updateStatusHoverCard: () => set({
|
||||
hovered: true,
|
||||
}),
|
||||
closeStatusHoverCard: (force = false) => set((state) => state.hovered && !force ? {} : {
|
||||
ref: null,
|
||||
statusId: null,
|
||||
hovered: false,
|
||||
}),
|
||||
},
|
||||
}));
|
||||
|
||||
export { useStatusHoverCardStore };
|
||||
const useStatusHoverCardActions = () => useStatusHoverCardStore((state) => state.actions);
|
||||
|
||||
export { useStatusHoverCardStore, useStatusHoverCardActions };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user