From e3d1363114ffeb8b1b8043d616c8a61bbf16c786 Mon Sep 17 00:00:00 2001 From: shubham Date: Thu, 23 May 2024 20:47:57 +0530 Subject: [PATCH] LSPS1: Adding clientPubkey to the order responses to filter orders --- views/Settings/LSPS1/OrdersPane.tsx | 17 ++++++++++++----- views/Settings/LSPS1/index.tsx | 8 +++++++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/views/Settings/LSPS1/OrdersPane.tsx b/views/Settings/LSPS1/OrdersPane.tsx index 95edcc51d..373fbc5e6 100644 --- a/views/Settings/LSPS1/OrdersPane.tsx +++ b/views/Settings/LSPS1/OrdersPane.tsx @@ -15,11 +15,14 @@ import { localeString } from '../../../utils/LocaleUtils'; import BackendUtils from '../../../utils/BackendUtils'; import LSPStore from '../../../stores/LSPStore'; +import NodeInfoStore from '../../../stores/NodeInfoStore'; + import { WarningMessage } from '../../../components/SuccessErrorMessage'; interface OrdersPaneProps { navigation: StackNavigationProp; LSPStore: LSPStore; + NodeInfoStore: NodeInfoStore; } interface OrdersPaneState { @@ -27,7 +30,7 @@ interface OrdersPaneState { isLoading: boolean; } -@inject('LSPStore') +@inject('LSPStore', 'NodeInfoStore') @observer export default class OrdersPane extends React.Component< OrdersPaneProps, @@ -69,14 +72,18 @@ export default class OrdersPane extends React.Component< let selectedOrders; if (BackendUtils.supportsLSPS1customMessage()) { selectedOrders = decodedResponses.filter( - (response) => response?.uri + (response) => + response?.uri && + response.clientPubkey === + this.props.NodeInfoStore.nodeInfo.nodeId ); } else if (BackendUtils.supportsLSPS1rest()) { selectedOrders = decodedResponses.filter( - (response) => response?.endpoint + (response) => + response?.endpoint && + response.clientPubkey === + this.props.NodeInfoStore.nodeInfo.nodeId ); - } else { - selectedOrders = decodedResponses; } const orders = selectedOrders.map((response) => { diff --git a/views/Settings/LSPS1/index.tsx b/views/Settings/LSPS1/index.tsx index b913eb4af..96c1594cb 100644 --- a/views/Settings/LSPS1/index.tsx +++ b/views/Settings/LSPS1/index.tsx @@ -36,6 +36,7 @@ import InvoicesStore from '../../../stores/InvoicesStore'; import ChannelsStore from '../../../stores/ChannelsStore'; import SettingsStore from '../../../stores/SettingsStore'; import FiatStore from '../../../stores/FiatStore'; +import NodeInfoStore from '../../../stores/NodeInfoStore'; import { Icon } from 'react-native-elements'; import LoadingIndicator from '../../../components/LoadingIndicator'; import LSPS1OrderResponse from '../../../components/LSPS1OrderResponse'; @@ -46,6 +47,7 @@ interface LSPS1Props { ChannelsStore: ChannelsStore; SettingsStore: SettingsStore; FiatStore: FiatStore; + NodeInfoStore: NodeInfoStore; navigation: StackNavigationProp; } @@ -67,7 +69,8 @@ interface LSPS1State { 'ChannelsStore', 'InvoicesStore', 'SettingsStore', - 'FiatStore' + 'FiatStore', + 'NodeInfoStore' ) @observer export default class LSPS1 extends React.Component { @@ -1016,6 +1019,9 @@ export default class LSPS1 extends React.Component { order: createOrderResponse }; + orderData.clientPubkey = + this.props.NodeInfoStore.nodeInfo.nodeId; + if ( BackendUtils.supportsLSPS1customMessage() ) {