Skip to content

Commit

Permalink
revert: fix: add scroll on overflow for walletconnect to dapps menu (#…
Browse files Browse the repository at this point in the history
…5406)

This reverts commit 4fa4e57.
  • Loading branch information
0xApotheosis committed Oct 4, 2023
1 parent 4fa4e57 commit 0996078
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 97 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { Accordion, MenuDivider, MenuGroup } from '@chakra-ui/react'
import type { SessionTypes } from '@walletconnect/types'
import { useWalletConnectV2 } from 'plugins/walletConnectToDapps/WalletConnectV2Provider'
import { useMemo } from 'react'
import { useTranslate } from 'react-polyglot'

import { WalletConnectButtons } from './ConnectDapp'
import { Session } from './Session'

export const DappHeaderMenuSummaryV2 = () => {
const translate = useTranslate()

const { sessionsByTopic, web3wallet } = useWalletConnectV2()

const sessions = useMemo(() => Object.values(sessionsByTopic), [sessionsByTopic])

const { connectedSessions, expiredSessions } = useMemo(() => {
const nowTtl = Date.now() / 1000
return sessions.reduce<{
connectedSessions: SessionTypes.Struct[]
expiredSessions: SessionTypes.Struct[]
}>(
(acc, session) => {
if (!session) return acc
if (session.expiry < nowTtl) {
acc.expiredSessions.push(session)
} else {
acc.connectedSessions.push(session)
}
return acc
},
{ connectedSessions: [], expiredSessions: [] },
)
}, [sessions])

if (!sessions.length || !web3wallet) return null

return (
<>
{connectedSessions.length > 0 && (
<MenuGroup
title={translate('plugins.walletConnectToDapps.header.connectedDapp')}
ml={3}
color='text.subtle'
>
<Accordion allowToggle defaultIndex={0} variant='default'>
{connectedSessions.map(session => (
<Session key={session.topic} session={session} />
))}
</Accordion>
</MenuGroup>
)}
{connectedSessions.length > 0 && expiredSessions.length > 0 && <MenuDivider />}
{expiredSessions.length > 0 && (
<MenuGroup
title={translate('plugins.walletConnectToDapps.header.staleDapp')}
ml={3}
color='text.subtle'
>
<Accordion allowToggle defaultIndex={0} variant='default'>
{expiredSessions.map(session => (
<Session key={session.topic} session={session} />
))}
</Accordion>
</MenuGroup>
)}
<MenuDivider />
<WalletConnectButtons m={4} />
</>
)
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ChevronDownIcon } from '@chakra-ui/icons'
import { AvatarGroup, Button, Menu, MenuButton, MenuList } from '@chakra-ui/react'
import type { SessionTypes } from '@walletconnect/types'
import { DappHeaderMenuSummary } from 'plugins/walletConnectToDapps/components/header/DappHeaderMenuSummary'
import { DappHeaderMenuSummaryV2 } from 'plugins/walletConnectToDapps/components/header/DappHeaderMenuSummaryV2'
import { useWalletConnectV2 } from 'plugins/walletConnectToDapps/WalletConnectV2Provider'
import { type FC, useMemo } from 'react'
import { useTranslate } from 'react-polyglot'
Expand Down Expand Up @@ -51,7 +51,7 @@ const WalletConnectV2ConnectedButton = () => {
[sessions],
)
return (
<Menu autoSelect={false} isLazy>
<Menu autoSelect={false}>
<MenuButton
as={Button}
leftIcon={
Expand Down Expand Up @@ -100,7 +100,7 @@ const WalletConnectV2ConnectedButton = () => {
flexDir='column'
pb={0}
>
<DappHeaderMenuSummary />
<DappHeaderMenuSummaryV2 />
</MenuList>
</Menu>
)
Expand Down

0 comments on commit 0996078

Please sign in to comment.