-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
revert: fix: add scroll on overflow for walletconnect to dapps menu (#…
- Loading branch information
1 parent
4fa4e57
commit 0996078
Showing
3 changed files
with
74 additions
and
97 deletions.
There are no files selected for viewing
94 changes: 0 additions & 94 deletions
94
src/plugins/walletConnectToDapps/components/header/DappHeaderMenuSummary.tsx
This file was deleted.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
src/plugins/walletConnectToDapps/components/header/DappHeaderMenuSummaryV2.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} /> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters