From 83f9f121fc416bd220de32919045d58a4e49b77e Mon Sep 17 00:00:00 2001 From: tjs Date: Mon, 17 Jul 2023 01:18:00 -0400 Subject: [PATCH] increase intervals for buildid and loading fills --- components/Layout.tsx | 65 ++++++++++++++++++++++++------------ components/MangoProvider.tsx | 2 +- 2 files changed, 44 insertions(+), 23 deletions(-) diff --git a/components/Layout.tsx b/components/Layout.tsx index 6ff4b63a..1216f962 100644 --- a/components/Layout.tsx +++ b/components/Layout.tsx @@ -32,16 +32,11 @@ export const sideBarAnimationDuration = 300 const termsLastUpdated = 1679441610978 const Layout = ({ children }: { children: ReactNode }) => { - const { connected } = useWallet() - const loadingMangoAccount = mangoStore((s) => s.mangoAccount.initialLoad) const [isCollapsed, setIsCollapsed] = useLocalStorageState( SIDEBAR_COLLAPSE_KEY, false ) - const [acceptTerms, setAcceptTerms] = useLocalStorageState( - ACCEPT_TERMS_KEY, - '' - ) + const { width } = useViewport() const { asPath } = useRouter() @@ -73,10 +68,6 @@ const Layout = ({ children }: { children: ReactNode }) => { particlesInit() }, []) - const showTermsOfUse = useMemo(() => { - return (!acceptTerms || acceptTerms < termsLastUpdated) && connected - }, [acceptTerms, connected]) - return (
{
- {connected && loadingMangoAccount ? ( -
- -
- ) : null} +
@@ -124,22 +111,56 @@ const Layout = ({ children }: { children: ReactNode }) => { {children}
+
- {showTermsOfUse ? ( - setAcceptTerms(Date.now())} - /> - ) : null}
) } export default Layout +const MangoAccountLoadingOverlay = () => { + const { connected } = useWallet() + const loadingMangoAccount = mangoStore((s) => s.mangoAccount.initialLoad) + + return ( + <> + {connected && loadingMangoAccount ? ( +
+ +
+ ) : null} + + ) +} + +const TermsOfUse = () => { + const { connected } = useWallet() + const [acceptTerms, setAcceptTerms] = useLocalStorageState( + ACCEPT_TERMS_KEY, + '' + ) + + const showTermsOfUse = useMemo(() => { + return (!acceptTerms || acceptTerms < termsLastUpdated) && connected + }, [acceptTerms, connected]) + + return ( + <> + {showTermsOfUse ? ( + setAcceptTerms(Date.now())} + /> + ) : null} + + ) +} + function DeployRefreshManager(): JSX.Element | null { const { t } = useTranslation('common') const [newBuildAvailable, setNewBuildAvailable] = useState(false) + useInterval(async () => { const response = await fetch('/api/build-id') const { buildId } = await response.json() @@ -148,7 +169,7 @@ function DeployRefreshManager(): JSX.Element | null { // There's a new version deployed that we need to load setNewBuildAvailable(true) } - }, 30000) + }, 300000) return ( { useInterval(async () => { const actions = mangoStore.getState().actions actions.loadMarketFills() - }, 6000) + }, 30000) // The websocket library solana/web3.js uses closes its websocket connection when the subscription list // is empty after opening its first time, preventing subsequent subscriptions from receiving responses.