Skip to content

Commit

Permalink
feat: do not show banners without connect wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
fairlighteth committed Oct 16, 2024
1 parent e3724a1 commit ea742c8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { lazy, PropsWithChildren, Suspense, useMemo } from 'react'
import { useMediaQuery } from '@cowprotocol/common-hooks'
import { isInjectedWidget } from '@cowprotocol/common-utils'
import { Color, Footer, GlobalCoWDAOStyles, Media, MenuBar } from '@cowprotocol/ui'
import { useWalletInfo } from '@cowprotocol/wallet'

import { NavLink } from 'react-router-dom'
import { ThemeProvider } from 'theme'
Expand Down Expand Up @@ -94,6 +95,8 @@ export function App() {
</HeaderControls>
)

const { account } = useWalletInfo()

return (
<ErrorBoundary>
<Suspense fallback={<LoadingApp />}>
Expand Down Expand Up @@ -129,7 +132,7 @@ export function App() {
)}

{/* CoW AMM banner */}
{!isInjectedWidgetMode && <CoWAmmBanner location={BannerLocation.Global} />}
{!isInjectedWidgetMode && account && <CoWAmmBanner location={BannerLocation.Global} />}

<styledEl.BodyWrapper>
<TopLevelModals />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useCallback, useMemo, useRef } from 'react'

import { TokenWithLogo } from '@cowprotocol/common-const'
import { useWalletInfo } from '@cowprotocol/wallet'

import { useVirtualizer } from '@tanstack/react-virtual'
import ms from 'ms.macro'
Expand Down Expand Up @@ -35,6 +36,8 @@ export function TokensVirtualList(props: TokensVirtualListProps) {
props
const { values: balances, isLoading: balancesLoading } = balancesState

const { account: connectedAccount } = useWalletInfo()

const isWalletConnected = !!account

const scrollTimeoutRef = useRef<NodeJS.Timeout>()
Expand Down Expand Up @@ -67,7 +70,7 @@ export function TokensVirtualList(props: TokensVirtualListProps) {

return (
<CommonListContainer id="tokens-list" ref={parentRef} onScroll={onScroll}>
<CoWAmmBanner location={BannerLocation.TokenSelector} />
{connectedAccount && <CoWAmmBanner location={BannerLocation.TokenSelector} />}
<styledEl.TokensInner ref={wrapperRef} style={{ height: virtualizer.getTotalSize() }}>
<styledEl.TokensScroller style={{ transform: `translateY(${items[0]?.start ?? 0}px)` }}>
{items.map((virtualRow) => {
Expand Down

0 comments on commit ea742c8

Please sign in to comment.