import React, { useEffect } from 'react'; import { Image, TouchableOpacity, View } from 'react-native'; import { List, Text } from 'react-native-paper'; import { SvgUri } from 'react-native-svg'; import { getSdkError } from '@walletconnect/utils'; import { useWalletConnect } from '../context/WalletConnectContext'; import styles from '../styles/stylesheet'; export default function WalletConnect() { const { web3wallet, activeSessions, setActiveSessions } = useWalletConnect(); const disconnect = async (sessionId: string) => { await web3wallet!.disconnectSession({ topic: sessionId, reason: getSdkError('USER_DISCONNECTED'), }); const sessions = web3wallet?.getActiveSessions() || {}; setActiveSessions(sessions); return; }; useEffect(() => { const sessions = web3wallet?.getActiveSessions() || {}; setActiveSessions(sessions); }, [web3wallet, setActiveSessions]); return ( {Object.keys(activeSessions).length > 0 ? ( <> Active Sessions {Object.entries(activeSessions).map(([sessionId, session]) => ( ( <> {session.peer.metadata.icons[0].endsWith('.svg') ? ( ) : ( )} )} // eslint-disable-next-line react/no-unstable-nested-components right={() => ( disconnect(sessionId)} style={styles.disconnectSession}> )} /> ))} ) : ( You have no active sessions )} ); }