refactor: move state detection to context so we can set it at the app level

This commit is contained in:
Derrick Hammer 2023-10-12 12:48:57 -04:00
parent 2ffc9a69f0
commit aa6ede68f0
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 3 additions and 3 deletions

View File

@ -35,6 +35,7 @@ type LumeContextType = {
setIsLoggedIn: (value: boolean) => void;
lume: LumeObject;
ready: boolean;
setReady: React.Dispatch<React.SetStateAction<boolean>>;
};
const networkRegistry = createNetworkRegistryClient();
@ -122,8 +123,6 @@ const LumeProvider = ({ children }) => {
useEffect(() => {
fetchAndUpdateNetworks();
loginComplete().then(() => isMounted.current && setIsLoggedIn(true));
init().then(() => isMounted.current && setReady(true));
const subDone = networkRegistry.subscribeToUpdates(() =>
fetchAndUpdateNetworks(),
@ -137,7 +136,8 @@ const LumeProvider = ({ children }) => {
}, [fetchAndUpdateNetworks]);
return (
<LumeContext.Provider value={{ lume, ready, isLoggedIn, setIsLoggedIn }}>
<LumeContext.Provider
value={{ lume, ready, setReady, isLoggedIn, setIsLoggedIn }}>
{children}
</LumeContext.Provider>
);