Update import/exports to be more tree-shake friendly
This commit is contained in:
2
lib/providers/theme/theme.ts
Normal file
2
lib/providers/theme/theme.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export { default as ThemeProvider, useTheme } from "$/providers/theme/ThemeProvider";
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { DangerMessageBlock, SuccessMessageBlock, WarningMessageBlock } from "$/component/message";
|
||||
import Toaster from "$/component/toaster/Toaster";
|
||||
import type { Toast, ToastProviderProps, ToastProviderState } from "$/types/ToasterTypes";
|
||||
import moment from "moment";
|
||||
import { createContext, useCallback, useContext, useMemo, useState } from "react";
|
||||
|
||||
|
||||
@@ -27,7 +26,7 @@ export default function ToasterProvider({
|
||||
const hideToast = useCallback(function hide(id: string){
|
||||
setToast((prev) => {
|
||||
if(prev.length === 1 && prev[0].id === id){
|
||||
const current = prev[0].hideTime > moment(new Date()).subtract(600, "ms").toDate() ? [...prev] : [];
|
||||
const current = prev[0].hideTime > new Date(Date.now() - 600) ? [...prev] : [];
|
||||
if(current.length > 0){
|
||||
setTimeout(() => hide(id), 600);
|
||||
}
|
||||
@@ -45,7 +44,7 @@ export default function ToasterProvider({
|
||||
}
|
||||
const id = crypto.randomUUID();
|
||||
|
||||
setToast((prev) => [ ...prev, { id, message, duration, hideTime: moment(new Date()).add(duration, "ms").toDate() } ]);
|
||||
setToast((prev) => [ ...prev, { id, message, duration, hideTime: new Date(Date.now() + duration) } ]);
|
||||
setTimeout(() => hideToast(id), duration);
|
||||
|
||||
return id;
|
||||
|
||||
Reference in New Issue
Block a user