File tree Expand file tree Collapse file tree 4 files changed +24
-9
lines changed
Expand file tree Collapse file tree 4 files changed +24
-9
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import { showSheet } from '../../store/utils/ui';
2323import { BodyM } from '../../styles/text' ;
2424import { giftOrder , giftPay , openChannel } from '../../utils/blocktank' ;
2525import { vibrate } from '../../utils/helpers' ;
26+ import { waitForLdkPeers } from '../../utils/lightning' ;
2627
2728const imageSrc = require ( '../../assets/illustrations/gift.png' ) ;
2829
@@ -117,6 +118,8 @@ const Loading = ({
117118 sheetRef . current ?. close ( ) ;
118119 } ;
119120
121+ await waitForLdkPeers ( ) ;
122+
120123 if ( maxInboundCapacity >= amount ) {
121124 await getWithLiquidity ( ) ;
122125 } else {
Original file line number Diff line number Diff line change 11import React , { memo , ReactElement } from 'react' ;
22import { useTranslation } from 'react-i18next' ;
33import { StyleSheet , View } from 'react-native' ;
4+ import { useSafeAreaInsets } from 'react-native-safe-area-context' ;
45import { WebView , WebViewMessageEvent } from 'react-native-webview' ;
56
67import NavigationHeader from '../../components/NavigationHeader' ;
@@ -15,6 +16,7 @@ const ShopMain = ({
1516} : RootStackScreenProps < 'ShopMain' > ) : ReactElement => {
1617 const { page } = route . params ;
1718 const { t } = useTranslation ( 'other' ) ;
19+ const insets = useSafeAreaInsets ( ) ;
1820
1921 const baseUrl = 'https://embed.bitrefill.com' ;
2022 // Payment method "bitcoin" gives a unified invoice
@@ -38,8 +40,9 @@ const ShopMain = ({
3840
3941 < View style = { styles . content } >
4042 < WebView
41- style = { styles . webview }
43+ containerStyle = { [ styles . webview , { marginBottom : insets . bottom } ] }
4244 source = { { uri } }
45+ forceDarkOn = { true }
4346 onMessage = { handleMessage }
4447 />
4548 </ View >
@@ -58,8 +61,6 @@ const styles = StyleSheet.create({
5861 webview : {
5962 backgroundColor : '#141716' ,
6063 borderRadius : 8 ,
61- flex : 1 ,
62- marginBottom : 16 ,
6364 } ,
6465} ) ;
6566
Original file line number Diff line number Diff line change @@ -399,12 +399,6 @@ export const giftPay = async (invoice: string): Promise<Result<IGift>> => {
399399} ;
400400
401401export const giftOrder = async ( code : string ) : Promise < Result < IGift > > => {
402- // Ensure we're properly connected to the Blocktank node prior to buying a channel.
403- const addPeersRes = await addPeers ( ) ;
404- if ( addPeersRes . isErr ( ) ) {
405- return err ( i18n . t ( 'other:bt_error_connect' ) ) ;
406- }
407-
408402 // Get the node ID to use for the order.
409403 const nodeIdResult = await getNodeId ( ) ;
410404 if ( nodeIdResult . isErr ( ) ) {
Original file line number Diff line number Diff line change @@ -1151,6 +1151,23 @@ export const waitForLdk = async (): Promise<void> => {
11511151 } ) ;
11521152} ;
11531153
1154+ export const waitForLdkPeers = async ( ) : Promise < void > => {
1155+ await tryNTimes ( {
1156+ toTry : async ( ) => {
1157+ const peersResult = await ldk . listPeers ( ) ;
1158+ if ( peersResult . isOk ( ) ) {
1159+ if ( peersResult . value . length > 0 ) {
1160+ return ok ( peersResult . value ) ;
1161+ }
1162+ return err ( 'no peers connected' ) ;
1163+ }
1164+ return err ( 'error getting peers' ) ;
1165+ } ,
1166+ times : 5 ,
1167+ interval : 1000 ,
1168+ } ) ;
1169+ } ;
1170+
11541171export const waitForLdkChannels = async ( ) : Promise < void > => {
11551172 await tryNTimes ( {
11561173 toTry : async ( ) => {
You can’t perform that action at this time.
0 commit comments