From c67e1b751d00f0e4b245058133b716d969206595 Mon Sep 17 00:00:00 2001 From: George Knee Date: Tue, 3 Oct 2023 14:06:32 +0100 Subject: [PATCH] use a combination of queries and event listeners --- packages/payment-proxy-client/src/App.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/payment-proxy-client/src/App.tsx b/packages/payment-proxy-client/src/App.tsx index 27f04fa86..22a87a00e 100644 --- a/packages/payment-proxy-client/src/App.tsx +++ b/packages/payment-proxy-client/src/App.tsx @@ -142,11 +142,14 @@ export default function App() { setPaymentChannelId(result.ChannelId); - // nitroClient.PaymentChannelUpdated(result.ChannelId, setPaymentChannelInfo); - // const paymentChannel = await nitroClient?.GetPaymentChannel( - // result.ChannelId - // ); - // setPaymentChannelInfo(paymentChannel); + nitroClient.PaymentChannelUpdated(result.ChannelId, setPaymentChannelInfo); + + // It's possible the channel updated before we registered the handler above, so + // query the channel once now to get the latest information: + + setPaymentChannelInfo( + await nitroClient?.GetPaymentChannel(result.ChannelId) + ); console.timeEnd("Create Payment Channel"); };