refactor: add inited state

This commit is contained in:
Derrick Hammer 2023-10-12 13:18:17 -04:00
parent 971991e808
commit cbfce62f95
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 12 additions and 1 deletions

View File

@ -34,6 +34,8 @@ export type LumeContextType = {
isLoggedIn: boolean;
setIsLoggedIn: (value: boolean) => void;
lume: LumeObject;
inited: boolean;
setInited: React.Dispatch<React.SetStateAction<boolean>>;
ready: boolean;
setReady: React.Dispatch<React.SetStateAction<boolean>>;
};
@ -45,6 +47,7 @@ const LumeContext = createContext<LumeContextType | undefined>(undefined);
const LumeProvider = ({ children }) => {
const [isLoggedIn, setIsLoggedIn] = useState(false);
const [ready, setReady] = useState<boolean>(false);
const [inited, setInited] = useState<boolean>(false);
const [lume, setLume] = useState<LumeObject>({ networks: [] });
const statusUnsubs = useRef(new Map());
const isMounted = useRef(true); // Use a ref to track mounting
@ -137,7 +140,15 @@ const LumeProvider = ({ children }) => {
return (
<LumeContext.Provider
value={{ lume, ready, setReady, isLoggedIn, setIsLoggedIn }}>
value={{
lume,
ready,
setReady,
isLoggedIn,
setIsLoggedIn,
inited,
setInited,
}}>
{children}
</LumeContext.Provider>
);