Skip to content

Commit

Permalink
make recommended changes
Browse files Browse the repository at this point in the history
  • Loading branch information
SarthakDev12 committed Jul 26, 2024
1 parent fecab48 commit 4ffddcc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 102 deletions.
9 changes: 0 additions & 9 deletions frontend/components/Loading.tsx

This file was deleted.

43 changes: 7 additions & 36 deletions frontend/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import '../styles/globals.scss';

import { ConfigProvider } from 'antd';
import type { AppProps } from 'next/app';
import { useEffect, useRef, useState } from 'react';
import { useEffect, useState } from 'react';

import { Layout } from '@/components/Layout';
import Loading from '@/components/Loading';
import { BalanceProvider } from '@/context/BalanceProvider';
import { ElectronApiProvider } from '@/context/ElectronApiProvider';
import { MasterSafeProvider } from '@/context/MasterSafeProvider';
Expand All @@ -21,39 +20,11 @@ import { WalletProvider } from '@/context/WalletProvider';
import { mainTheme } from '@/theme';

export default function App({ Component, pageProps }: AppProps) {
const isMounted = useRef(false);
const [isLoaded, setIsLoaded] = useState(false);
const [loadingTimeReached, setLoadingTimeReached] = useState(false);

const [isMounted, setIsMounted] = useState(false);
useEffect(() => {
isMounted.current = true;

const handleLoad = () => {
setIsLoaded(true);
};
const checkStylesLoaded = () => {
const styles = document.querySelectorAll('link[rel="stylesheet"]');
if (styles.length > 0) {
handleLoad();
}
};

const timer = setTimeout(() => {
setLoadingTimeReached(true);
}, 1000);

checkStylesLoaded();
window.addEventListener('load', checkStylesLoaded);
return () => {
isMounted.current = false;
clearTimeout(timer);
window.removeEventListener('load', checkStylesLoaded);
};
setIsMounted(true);
}, []);

if (!loadingTimeReached || !isLoaded) {
return <Loading />;
}
return (
<ElectronApiProvider>
<StoreProvider>
Expand All @@ -67,13 +38,13 @@ export default function App({ Component, pageProps }: AppProps) {
<SetupProvider>
<SettingsProvider>
<StakingContractInfoProvider>
{isMounted ? (
<ConfigProvider theme={mainTheme}>
<ConfigProvider theme={mainTheme}>
{isMounted ? (
<Layout>
<Component {...pageProps} />
</Layout>
</ConfigProvider>
) : null}
) : null}
</ConfigProvider>
</StakingContractInfoProvider>
</SettingsProvider>
</SetupProvider>
Expand Down
57 changes: 0 additions & 57 deletions frontend/pages/_document.tsx

This file was deleted.

0 comments on commit 4ffddcc

Please sign in to comment.