Skip to content

Commit

Permalink
POS: add confirmation preference scaffolding
Browse files Browse the repository at this point in the history
  • Loading branch information
kaloudis committed Jan 17, 2023
1 parent 18323b9 commit 1fda264
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 37 deletions.
1 change: 1 addition & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@
"views.Settings.POS.enableSquare": "Enable Square POS integration",
"views.Settings.POS.accessToken": "Square Access token",
"views.Settings.POS.locationId": "Square Location ID",
"views.Settings.POS.confPref": "Confirmation preference",
"views.Transaction.title": "Transaction",
"views.Transaction.totalFees": "Total Fees",
"views.Transaction.transactionHash": "Transaction Hash",
Expand Down
8 changes: 4 additions & 4 deletions stores/InvoicesStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,16 @@ export default class InvoicesStore {
this.getNewAddress(addressType ? { type: addressType } : null);
}

const rHash = this.createInvoice(
return this.createInvoice(
memo,
value,
expiry,
lnurl,
ampInvoice,
routeHints
);

return { rHash, onChainAddress: this.onChainAddress };
).then((rHash: string) => {
return { rHash, onChainAddress: this.onChainAddress };
});
};

@action
Expand Down
26 changes: 12 additions & 14 deletions views/Receive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ export default class Receive extends React.Component<
};

subscribeInvoice = (rHash: string, onChainAddress: string) => {
console.log('!!!subscribeInvoice', { rHash, onChainAddress });
const { InvoicesStore, PosStore, SettingsStore } = this.props;
const { orderId, orderAmount, orderTip, value } = this.state;
const { implementation, settings } = SettingsStore;
Expand Down Expand Up @@ -237,22 +236,21 @@ export default class Receive extends React.Component<
}

if (implementation === 'lnd') {
// BackendUtils.subscribeInvoice(rHash).then((response: any) => {
// const result = response.result;
// if (result && result.settled) {
// setWatchedInvoicePaid(result.amt_paid_sat);
// if (orderId)
// PosStore.makePayment({
// orderId,
// orderAmount,
// orderTip
// });
// }
// });
BackendUtils.subscribeInvoice(rHash).then((response: any) => {
const result = response.result;
if (result && result.settled) {
setWatchedInvoicePaid(result.amt_paid_sat);
if (orderId)
PosStore.makePayment({
orderId,
orderAmount,
orderTip
});
}
});

BackendUtils.subscribeTransactions().then((response: any) => {
const result = response.result;
console.log('RESULT', result);
if (
result.dest_addresses.includes(onChainAddress) &&
result.num_confirmations >= numConfPreference &&
Expand Down
43 changes: 24 additions & 19 deletions views/Settings/PointOfSale.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,26 +233,31 @@ export default class PointOfSale extends React.Component<
}}
/>

<DropdownSetting
title={localeString(
'views.Settings.Display.defaultView'
)}
selectedValue={confirmationPreference}
onValueChange={async (value: string) => {
this.setState({
confirmationPreference: value
});
await updateSettings({
pos: {
squareEnabled,
squareAccessToken,
squareLocationId,
{false && (
<DropdownSetting
title={localeString(
'views.Settings.POS.confPref'
)}
selectedValue={confirmationPreference}
onValueChange={async (
value: string
) => {
this.setState({
confirmationPreference: value
}
});
}}
values={POS_CONF_PREF_KEYS}
/>
});
await updateSettings({
pos: {
squareEnabled,
squareAccessToken,
squareLocationId,
confirmationPreference:
value
}
});
}}
values={POS_CONF_PREF_KEYS}
/>
)}
</>
)}
</ScrollView>
Expand Down
2 changes: 2 additions & 0 deletions views/Wallet/PosPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import PosStore from '../../stores/PosStore';
import UnitsStore from '../../stores/UnitsStore';
import SettingsStore from '../../stores/SettingsStore';

import Order from '../../models/Order';

import { themeColor } from '../../utils/ThemeUtils';
import { localeString } from '../../utils/LocaleUtils';

Expand Down

0 comments on commit 1fda264

Please sign in to comment.