Skip to content

Commit

Permalink
LSPS1: Adding clientPubkey to the order responses to filter orders
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamkmr04 committed May 23, 2024
1 parent e1a792c commit e3d1363
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
17 changes: 12 additions & 5 deletions views/Settings/LSPS1/OrdersPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,22 @@ 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<any, any>;
LSPStore: LSPStore;
NodeInfoStore: NodeInfoStore;
}

interface OrdersPaneState {
orders: any[];
isLoading: boolean;
}

@inject('LSPStore')
@inject('LSPStore', 'NodeInfoStore')
@observer
export default class OrdersPane extends React.Component<
OrdersPaneProps,
Expand Down Expand Up @@ -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) => {
Expand Down
8 changes: 7 additions & 1 deletion views/Settings/LSPS1/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -46,6 +47,7 @@ interface LSPS1Props {
ChannelsStore: ChannelsStore;
SettingsStore: SettingsStore;
FiatStore: FiatStore;
NodeInfoStore: NodeInfoStore;
navigation: StackNavigationProp<any, any>;
}

Expand All @@ -67,7 +69,8 @@ interface LSPS1State {
'ChannelsStore',
'InvoicesStore',
'SettingsStore',
'FiatStore'
'FiatStore',
'NodeInfoStore'
)
@observer
export default class LSPS1 extends React.Component<LSPS1Props, LSPS1State> {
Expand Down Expand Up @@ -1016,6 +1019,9 @@ export default class LSPS1 extends React.Component<LSPS1Props, LSPS1State> {
order: createOrderResponse
};

orderData.clientPubkey =
this.props.NodeInfoStore.nodeInfo.nodeId;

if (
BackendUtils.supportsLSPS1customMessage()
) {
Expand Down

0 comments on commit e3d1363

Please sign in to comment.