@@ -18,11 +18,33 @@ type ConnectionInfoModalProps = {
1818} ;
1919
2020function ConnectionInfoModal ( { visible, onClose } : ConnectionInfoModalProps ) {
21+ const { shadow } = useThemeColor ( "shadow" ) ;
2122 const selectedWalletId = useAppStore ( ( store ) => store . selectedWalletId ) ;
2223 const wallets = useAppStore ( ( store ) => store . wallets ) ;
2324 const capabilities = wallets [ selectedWalletId ] . nwcCapabilities ;
2425 const nwcClient = useAppStore ( ( store ) => store . nwcClient ) ;
25- const { shadow } = useThemeColor ( "shadow" ) ;
26+ const [ relayStatuses , setRelayStatuses ] = React . useState < boolean [ ] > ( [ ] ) ;
27+ React . useEffect ( ( ) => {
28+ if ( ! nwcClient ) {
29+ return ;
30+ }
31+ ( async ( ) => {
32+ const _relayStatuses = [ ] ;
33+ for ( const relayUrl of nwcClient . relayUrls ) {
34+ try {
35+ await nwcClient . pool . ensureRelay ( relayUrl , {
36+ connectionTimeout : 2000 ,
37+ } ) ;
38+ _relayStatuses . push ( true ) ;
39+ } catch ( error ) {
40+ console . error ( "Failed to connect to relay" , { relayUrl, error } ) ;
41+ _relayStatuses . push ( false ) ;
42+ }
43+ }
44+ setRelayStatuses ( _relayStatuses ) ;
45+ } ) ( ) ;
46+ } , [ nwcClient ] ) ;
47+
2648 return (
2749 < Modal
2850 transparent
@@ -82,7 +104,7 @@ function ConnectionInfoModal({ visible, onClose }: ConnectionInfoModalProps) {
82104 >
83105 < View className = "flex gap-2" >
84106 < Text className = "font-semibold2" > Relays</ Text >
85- { nwcClient ?. relayUrls . map ( ( relayUrl ) => (
107+ { nwcClient ?. relayUrls . map ( ( relayUrl , index ) => (
86108 < View
87109 className = "flex flex-row items-center gap-2"
88110 key = { relayUrl }
@@ -91,9 +113,7 @@ function ConnectionInfoModal({ visible, onClose }: ConnectionInfoModalProps) {
91113 < View
92114 className = { cn (
93115 "rounded-full w-2 h-2" ,
94- nwcClient . pool . listConnectionStatus ( ) . get ( relayUrl )
95- ? "bg-receive"
96- : "bg-destructive" ,
116+ relayStatuses [ index ] ? "bg-receive" : "bg-destructive" ,
97117 ) }
98118 > </ View >
99119 </ View >
0 commit comments