increase intervals for buildid and loading fills

This commit is contained in:
tjs 2023-07-17 01:18:00 -04:00
parent 2f92c0f3a5
commit 83f9f121fc
2 changed files with 44 additions and 23 deletions

View File

@ -32,16 +32,11 @@ export const sideBarAnimationDuration = 300
const termsLastUpdated = 1679441610978 const termsLastUpdated = 1679441610978
const Layout = ({ children }: { children: ReactNode }) => { const Layout = ({ children }: { children: ReactNode }) => {
const { connected } = useWallet()
const loadingMangoAccount = mangoStore((s) => s.mangoAccount.initialLoad)
const [isCollapsed, setIsCollapsed] = useLocalStorageState( const [isCollapsed, setIsCollapsed] = useLocalStorageState(
SIDEBAR_COLLAPSE_KEY, SIDEBAR_COLLAPSE_KEY,
false false
) )
const [acceptTerms, setAcceptTerms] = useLocalStorageState(
ACCEPT_TERMS_KEY,
''
)
const { width } = useViewport() const { width } = useViewport()
const { asPath } = useRouter() const { asPath } = useRouter()
@ -73,10 +68,6 @@ const Layout = ({ children }: { children: ReactNode }) => {
particlesInit() particlesInit()
}, []) }, [])
const showTermsOfUse = useMemo(() => {
return (!acceptTerms || acceptTerms < termsLastUpdated) && connected
}, [acceptTerms, connected])
return ( return (
<main <main
className={`${ttCommons.variable} ${ttCommonsExpanded.variable} ${ttCommonsMono.variable} font-sans`} className={`${ttCommons.variable} ${ttCommonsExpanded.variable} ${ttCommonsMono.variable} font-sans`}
@ -84,11 +75,7 @@ const Layout = ({ children }: { children: ReactNode }) => {
<div className="fixed z-30"> <div className="fixed z-30">
<SuccessParticles /> <SuccessParticles />
</div> </div>
{connected && loadingMangoAccount ? ( <MangoAccountLoadingOverlay />
<div className="fixed z-30 flex h-screen w-full items-center justify-center bg-[rgba(0,0,0,0.7)]">
<BounceLoader />
</div>
) : null}
<div className="flex-grow bg-th-bkg-1 text-th-fgd-2 transition-all"> <div className="flex-grow bg-th-bkg-1 text-th-fgd-2 transition-all">
<div className="fixed bottom-0 left-0 z-20 w-full md:hidden"> <div className="fixed bottom-0 left-0 z-20 w-full md:hidden">
<BottomBar /> <BottomBar />
@ -124,22 +111,56 @@ const Layout = ({ children }: { children: ReactNode }) => {
{children} {children}
</div> </div>
<DeployRefreshManager /> <DeployRefreshManager />
<TermsOfUse />
</div> </div>
{showTermsOfUse ? (
<TermsOfUseModal
isOpen={showTermsOfUse}
onClose={() => setAcceptTerms(Date.now())}
/>
) : null}
</main> </main>
) )
} }
export default Layout export default Layout
const MangoAccountLoadingOverlay = () => {
const { connected } = useWallet()
const loadingMangoAccount = mangoStore((s) => s.mangoAccount.initialLoad)
return (
<>
{connected && loadingMangoAccount ? (
<div className="fixed z-30 flex h-screen w-full items-center justify-center bg-[rgba(0,0,0,0.7)]">
<BounceLoader />
</div>
) : 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 ? (
<TermsOfUseModal
isOpen={showTermsOfUse}
onClose={() => setAcceptTerms(Date.now())}
/>
) : null}
</>
)
}
function DeployRefreshManager(): JSX.Element | null { function DeployRefreshManager(): JSX.Element | null {
const { t } = useTranslation('common') const { t } = useTranslation('common')
const [newBuildAvailable, setNewBuildAvailable] = useState(false) const [newBuildAvailable, setNewBuildAvailable] = useState(false)
useInterval(async () => { useInterval(async () => {
const response = await fetch('/api/build-id') const response = await fetch('/api/build-id')
const { buildId } = await response.json() 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 // There's a new version deployed that we need to load
setNewBuildAvailable(true) setNewBuildAvailable(true)
} }
}, 30000) }, 300000)
return ( return (
<Transition <Transition

View File

@ -48,7 +48,7 @@ const HydrateStore = () => {
useInterval(async () => { useInterval(async () => {
const actions = mangoStore.getState().actions const actions = mangoStore.getState().actions
actions.loadMarketFills() actions.loadMarketFills()
}, 6000) }, 30000)
// The websocket library solana/web3.js uses closes its websocket connection when the subscription list // 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. // is empty after opening its first time, preventing subsequent subscriptions from receiving responses.