Migrate remaining notification console methods to zustand (#873)

This commit is contained in:
Steve Faulkner
2021-06-09 13:11:12 -07:00
committed by GitHub
parent fc9f4c5583
commit bcc9f8dd32
17 changed files with 96 additions and 135 deletions

View File

@@ -1,14 +1,25 @@
import create, { UseStore } from "zustand";
import { ConsoleData } from "../Explorer/Menus/NotificationConsole/ConsoleData";
export interface NotificationConsoleState {
isExpanded: boolean;
inProgressConsoleDataIdToBeDeleted: string;
consoleData: ConsoleData | undefined;
expandConsole: () => void;
// TODO Remove this method. Add a `closeConsole` method instead
setIsExpanded: (isExpanded: boolean) => void;
// TODO These two methods badly need a refactor. Not very react friendly.
setNotificationConsoleData: (consoleData: ConsoleData) => void;
setInProgressConsoleDataIdToBeDeleted: (id: string) => void;
}
export const useNotificationConsole: UseStore<NotificationConsoleState> = create((set) => ({
isExpanded: false,
consoleData: undefined,
inProgressConsoleDataIdToBeDeleted: "",
expandConsole: () => set((state) => ({ ...state, isExpanded: true })),
setIsExpanded: (isExpanded) => set((state) => ({ ...state, isExpanded })),
setNotificationConsoleData: (consoleData: ConsoleData) => set((state) => ({ ...state, consoleData })),
setInProgressConsoleDataIdToBeDeleted: (id: string) =>
set((state) => ({ ...state, inProgressConsoleDataIdToBeDeleted: id })),
}));