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 { web3wallet } from '../utils/wallet-connect/WalletConnectUtils'; import styles from '../styles/stylesheet'; export default function WalletConnect() { const { 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); }, [setActiveSessions]); return ( {Object.keys(activeSessions).length > 0 ? ( <> Active Sessions {Object.entries(activeSessions).map(([sessionId, session]) => ( ( <> {session.peer.metadata.icons[0].endsWith('.svg') ? ( ) : ( )} )} right={() => ( disconnect(sessionId)} style={{ display: 'flex', justifyContent: 'center' }}> )} /> ))} ) : ( You have no active sessions )} ); }