diff --git a/stores/LSPStore.ts b/stores/LSPStore.ts index dbd38eea5..392e0c303 100644 --- a/stores/LSPStore.ts +++ b/stores/LSPStore.ts @@ -19,6 +19,8 @@ export default class LSPStore { @observable public feeId: string | undefined; @observable public pubkey: string; @observable public host: string; + @observable public restHost: string; + @observable public loading: boolean = true; @observable public error: boolean = false; @observable public error_msg: string = ''; @observable public showLspSettings: boolean = false; @@ -62,6 +64,7 @@ export default class LSPStore { public resetLSPS1Data = () => { this.createOrderResponse = {}; this.getInfoData = {}; + this.loading = true; }; getLSPHost = () => @@ -321,10 +324,12 @@ export default class LSPStore { if (data.id === '42') { this.getInfoData = data; + this.loading = false; } else if (data.id === '52') { this.getOrderResponse = data; } else { this.createOrderResponse = data; + this.loading = false; } }; @@ -363,7 +368,7 @@ export default class LSPStore { }; @action - public getinfoREST = (host = 'https://testnet-lsps1.lnolymp.us') => { + public getinfoREST = (host: string) => { const endpoint = `${host}/api/v1/get_info`; console.log('Fetching data from:', endpoint); @@ -373,6 +378,7 @@ export default class LSPStore { if (response.info().status === 200) { const responseData = JSON.parse(response.data); this.getInfoData = responseData; + this.loading = false; } else { throw new Error( `Failed to fetch get_info: ${response.info().status}` @@ -386,7 +392,7 @@ export default class LSPStore { }; @action - public createorderREST = (host: string, state: any) => { + public createorderREST = (state: any) => { const data = JSON.stringify({ lsp_balance_sat: state.lspBalanceSat, client_balance_sat: state.clientBalanceSat, @@ -402,8 +408,8 @@ export default class LSPStore { announce_channel: true, public_key: this.pubkey }); - const endpoint = `${host}/api/v1/create_order`; - + this.loading = true; + const endpoint = `${state.host}/api/v1/create_order`; console.log('Sending data to:', endpoint); return ReactNativeBlobUtil.fetch( @@ -417,6 +423,7 @@ export default class LSPStore { .then((response) => { const responseData = JSON.parse(response.data); this.createOrderResponse = responseData; + this.loading = false; console.log('Response received:', responseData); }) .catch((error) => { diff --git a/views/Settings/LSPS1/Settings.tsx b/views/Settings/LSPS1/Settings.tsx index 2e65d455e..2c347a155 100644 --- a/views/Settings/LSPS1/Settings.tsx +++ b/views/Settings/LSPS1/Settings.tsx @@ -109,13 +109,12 @@ export default class LSPS1Settings extends React.Component< LSPStore.host = text; }} /> - {inputsChanged && ( -