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,23 +1,17 @@
import * as _ from "underscore";
import { ConsoleDataType } from "../Explorer/Menus/NotificationConsole/NotificationConsoleComponent";
const _global = typeof self === "undefined" ? window : self;
import { ConsoleDataType } from "../Explorer/Menus/NotificationConsole/ConsoleData";
import { useNotificationConsole } from "../hooks/useNotificationConsole";
function log(type: ConsoleDataType, message: string): () => void {
const dataExplorer = _global.dataExplorer;
if (dataExplorer) {
const id = _.uniqueId();
const date = new Intl.DateTimeFormat("en-EN", {
hour12: true,
hour: "numeric",
minute: "numeric",
}).format(new Date());
const id = _.uniqueId();
const date = new Intl.DateTimeFormat("en-EN", {
hour12: true,
hour: "numeric",
minute: "numeric",
}).format(new Date());
dataExplorer.logConsoleData({ type, date, message, id });
return () => dataExplorer.deleteInProgressConsoleDataWithId(id);
}
return () => undefined;
useNotificationConsole.getState().setNotificationConsoleData({ type, date, message, id });
return () => useNotificationConsole.getState().setInProgressConsoleDataIdToBeDeleted(id);
}
export const logConsoleProgress = (msg: string): (() => void) => log(ConsoleDataType.InProgress, msg);