@@ -3,7 +3,7 @@ import { StyleSheet, View } from "react-native";
3
3
import { Button , Card , Layout , Text } from "@ui-kitten/components" ;
4
4
import { oreoWallet } from "@/data/wallet/oreowalletWallet" ;
5
5
import { Network } from "@/data/constants" ;
6
- import { useCallback , useRef , useState } from "react" ;
6
+ import { useCallback , useEffect , useRef , useState } from "react" ;
7
7
import * as Uint8ArrayUtils from "@/utils/uint8Array" ;
8
8
import { useFacade } from "@/data/facades" ;
9
9
import { Output } from "@/data/facades/wallet/types" ;
@@ -219,15 +219,13 @@ export default function MenuDebugBrowser() {
219
219
} ,
220
220
) ;
221
221
222
- const handlePresentModalPress = useCallback ( ( ) => {
223
- bottomSheetModalRef . current ?. present ( ) ;
224
- setAccountModalVisible ( true ) ;
225
- } , [ ] ) ;
226
-
227
- const handleDismissModalPress = useCallback ( ( ) => {
228
- bottomSheetModalRef . current ?. dismiss ( ) ;
229
- setAccountModalVisible ( false ) ;
230
- } , [ ] ) ;
222
+ useEffect ( ( ) => {
223
+ if ( accountModalVisible ) {
224
+ bottomSheetModalRef . current ?. present ( ) ;
225
+ } else {
226
+ bottomSheetModalRef . current ?. dismiss ( ) ;
227
+ }
228
+ } , [ accountModalVisible ] ) ;
231
229
232
230
const renderBackdrop = useCallback (
233
231
( props : any ) => (
@@ -379,7 +377,10 @@ export default function MenuDebugBrowser() {
379
377
enablePanDownToClose
380
378
backdropComponent = { renderBackdrop }
381
379
onDismiss = { ( ) => {
382
- messageHandler . current . updateActiveAccount ( null ) ;
380
+ if ( messageHandler . current . connectRequest ) {
381
+ messageHandler . current . connectRequest . resolve ( null ) ;
382
+ messageHandler . current . connectRequest = null ;
383
+ }
383
384
setAccountModalVisible ( false ) ;
384
385
} }
385
386
backgroundStyle = { styles . bottomSheetModal }
@@ -391,7 +392,7 @@ export default function MenuDebugBrowser() {
391
392
style = { { width : 48 , height : 48 } }
392
393
/>
393
394
< Layout style = { { gap : 2 } } >
394
- < Text category = "h5" > Iron Fish Bridge </ Text >
395
+ < Text category = "h5" > Connect Account </ Text >
395
396
< Text category = "s2" appearance = "hint" >
396
397
{ network }
397
398
</ Text >
@@ -412,34 +413,36 @@ export default function MenuDebugBrowser() {
412
413
>
413
414
< Button
414
415
onPress = { ( ) => {
416
+ messageHandler . current . updateActiveAccount ( null ) ;
417
+ setAccountModalVisible ( false ) ;
418
+ } }
419
+ style = { { flex : 1 } }
420
+ appearance = "outline"
421
+ >
422
+ Cancel
423
+ </ Button >
424
+ < Button
425
+ onPress = { async ( ) => {
415
426
if ( ! account . data ) {
416
427
console . error ( "No account loaded" ) ;
417
428
return ;
418
429
}
419
- messageHandler . current . updateActiveAccount ( {
430
+ await messageHandler . current . updateActiveAccount ( {
420
431
name : account . data . name ,
421
432
address : account . data . publicAddress ,
422
433
} ) ;
423
- handleDismissModalPress ( ) ;
434
+ setAccountModalVisible ( false ) ;
424
435
} }
425
436
style = { { flex : 1 } }
426
437
>
427
438
Confirm
428
439
</ Button >
429
- < Button
430
- onPress = { ( ) => {
431
- messageHandler . current . updateActiveAccount ( null ) ;
432
- handleDismissModalPress ( ) ;
433
- } }
434
- style = { { flex : 1 } }
435
- appearance = "outline"
436
- >
437
- Cancel
438
- </ Button >
439
440
</ Layout >
440
441
</ BottomSheetView >
441
442
</ BottomSheetModal >
442
443
< SendTransactionModal
444
+ network = { network }
445
+ renderBackdrop = { renderBackdrop }
443
446
sendTransactionData = { sendTransactionData }
444
447
cancel = { ( ) => {
445
448
messageHandler . current . rejectSendTransactionRequest ( ) ;
@@ -457,7 +460,7 @@ export default function MenuDebugBrowser() {
457
460
onMessage = { ( event ) => {
458
461
messageHandler . current . handleMessage (
459
462
event . nativeEvent . data ,
460
- handlePresentModalPress ,
463
+ ( ) => setAccountModalVisible ( true ) ,
461
464
( data ) => {
462
465
setSendTransactionData ( data ) ;
463
466
} ,
0 commit comments