mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-20 09:20:16 +00:00
Migrate remaining notification console methods to zustand (#873)
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user