Skip to content

Commit 5745649

Browse files
authored
Fix display of BTC units (#808)
1 parent 12fe437 commit 5745649

File tree

12 files changed

+72
-28
lines changed

12 files changed

+72
-28
lines changed

components/Amount.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { Body } from './text/Body';
1111

1212
export const satoshisPerBTC = 100000000;
1313

14-
type Units = 'sats' | 'btc' | 'fiat';
14+
type Units = 'sats' | 'BTC' | 'fiat';
1515

1616
interface AmountDisplayProps {
1717
amount: string;
@@ -42,7 +42,7 @@ function AmountDisplay({
4242
console.error('Must include a symbol when rendering fiat');
4343
}
4444

45-
const actualSymbol = unit === 'btc' ? '₿' : symbol;
45+
const actualSymbol = unit === 'BTC' ? '₿' : symbol;
4646

4747
const Pending = () => (
4848
<View
@@ -88,7 +88,7 @@ function AmountDisplay({
8888
</View>
8989
</Row>
9090
);
91-
case 'btc':
91+
case 'BTC':
9292
case 'fiat':
9393
if (rtl) {
9494
return (

stores/InvoicesStore.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import hashjs from 'hash.js';
88
import Invoice from './../models/Invoice';
99
import SettingsStore from './SettingsStore';
1010
import RESTUtils from './../utils/RESTUtils';
11+
import { localeString } from './../utils/LocaleUtils';
1112

1213
export default class InvoicesStore {
1314
@observable paymentRequest: string;
@@ -162,7 +163,12 @@ export default class InvoicesStore {
162163
Alert.alert(
163164
`[error] ${lnurl.domain} says:`,
164165
data.reason,
165-
[{ text: 'OK', onPress: () => void 0 }],
166+
[
167+
{
168+
text: localeString('general.error'),
169+
onPress: () => void 0
170+
}
171+
],
166172
{ cancelable: false }
167173
);
168174
}

stores/UnitsStore.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import SettingsStore from './SettingsStore';
33
import FiatStore from './FiatStore';
44
import FeeUtils from './../utils/FeeUtils';
55

6-
type Units = 'sats' | 'btc' | 'fiat';
6+
type Units = 'sats' | 'BTC' | 'fiat';
77

88
export const satoshisPerBTC = 100000000;
99

@@ -33,13 +33,13 @@ export default class UnitsStore {
3333
const { fiat } = settings;
3434

3535
if (!fiat || fiat === 'Disabled') {
36-
this.units = this.units == 'sats' ? 'btc' : 'sats';
36+
this.units = this.units == 'sats' ? 'BTC' : 'sats';
3737
} else {
3838
switch (this.units) {
3939
case 'sats':
40-
this.units = 'btc';
40+
this.units = 'BTC';
4141
break;
42-
case 'btc':
42+
case 'BTC':
4343
this.units = 'fiat';
4444
break;
4545
case 'fiat':
@@ -67,10 +67,10 @@ export default class UnitsStore {
6767
const negative = sats < 0;
6868
const absValueSats = Math.abs(sats);
6969

70-
if (units === 'btc') {
70+
if (units === 'BTC') {
7171
return {
7272
amount: FeeUtils.toFixed(absValueSats / satoshisPerBTC),
73-
unit: 'btc',
73+
unit: 'BTC',
7474
negative,
7575
space: false
7676
};
@@ -129,7 +129,7 @@ export default class UnitsStore {
129129
const units = fixedUnits || this.units;
130130

131131
const [wholeSats] = value.toString().split('.');
132-
if (units === 'btc') {
132+
if (units === 'BTC') {
133133
// handle negative values
134134
const valueToProcess = (wholeSats && wholeSats.toString()) || '0';
135135
if (valueToProcess.includes('-')) {

views/Accounts/ImportAccountQRScanner.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const ImportAccountQRScanner = (props: ImportAccountQRScannerProps) => {
4848
Alert.alert(
4949
localeString('general.error'),
5050
localeString('views.LNDConnectConfigQRScanner.error'),
51-
[{ text: 'OK', onPress: () => void 0 }],
51+
[{ text: localeString('general.ok'), onPress: () => void 0 }],
5252
{ cancelable: false }
5353
);
5454
}
@@ -85,7 +85,7 @@ const ImportAccountQRScanner = (props: ImportAccountQRScannerProps) => {
8585
Alert.alert(
8686
localeString('general.error'),
8787
localeString('views.LNDConnectConfigQRScanner.error'),
88-
[{ text: 'OK', onPress: () => void 0 }],
88+
[{ text: localeString('general.ok'), onPress: () => void 0 }],
8989
{ cancelable: false }
9090
);
9191
}

views/AddressQRScanner.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import * as React from 'react';
22
import { Alert } from 'react-native';
33
import { observer } from 'mobx-react';
4+
45
import QRCodeScanner from './../components/QRCodeScanner';
6+
57
import handleAnything from './../utils/handleAnything';
8+
import { localeString } from './../utils/LocaleUtils';
69

710
interface AddressQRProps {
811
navigation: any;
@@ -29,9 +32,14 @@ export default class AddressQRScanner extends React.Component<
2932
})
3033
.catch((err) => {
3134
Alert.alert(
32-
'Error',
35+
localeString('general.error'),
3336
err.message,
34-
[{ text: 'OK', onPress: () => void 0 }],
37+
[
38+
{
39+
text: localeString('general.ok'),
40+
onPress: () => void 0
41+
}
42+
],
3543
{ cancelable: false }
3644
);
3745

views/BTCPayConfigQRScanner.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ export default class BTCPayConfigQRScanner extends React.Component<
2929
Alert.alert(
3030
localeString('general.error'),
3131
SettingsStore.btcPayError,
32-
[{ text: 'OK', onPress: () => void 0 }],
32+
[
33+
{
34+
text: localeString('general.ok'),
35+
onPress: () => void 0
36+
}
37+
],
3338
{ cancelable: false }
3439
);
3540
}
@@ -39,7 +44,12 @@ export default class BTCPayConfigQRScanner extends React.Component<
3944
Alert.alert(
4045
localeString('general.error'),
4146
localeString('views.BTCPayConfigQRScanner.error'),
42-
[{ text: 'OK', onPress: () => void 0 }],
47+
[
48+
{
49+
text: localeString('general.ok'),
50+
onPress: () => void 0
51+
}
52+
],
4353
{ cancelable: false }
4454
);
4555

views/LNDConnectConfigQRScanner.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default class LNDConnectConfigQRScanner extends React.Component<
2929
Alert.alert(
3030
localeString('general.error'),
3131
localeString('views.LNDConnectConfigQRScanner.error'),
32-
[{ text: 'OK', onPress: () => void 0 }],
32+
[{ text: localeString('general.ok'), onPress: () => void 0 }],
3333
{ cancelable: false }
3434
);
3535

views/LnurlAuth.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,12 @@ export default class LnurlAuth extends React.Component<
182182
Alert.alert(
183183
`[error] ${domain} says:`,
184184
data.reason,
185-
[{ text: 'OK', onPress: () => void 0 }],
185+
[
186+
{
187+
text: localeString('general.ok'),
188+
onPress: () => void 0
189+
}
190+
],
186191
{ cancelable: false }
187192
);
188193
return;

views/LnurlChannel.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export default class LnurlChannel extends React.Component<
6262
Alert.alert(
6363
localeString('views.LnurlPay.LnurlPay.invalidParams'),
6464
err.message,
65-
[{ text: 'OK', onPress: () => void 0 }],
65+
[{ text: localeString('general.ok'), onPress: () => void 0 }],
6666
{ cancelable: false }
6767
);
6868
}
@@ -160,7 +160,12 @@ export default class LnurlChannel extends React.Component<
160160
Alert.alert(
161161
`[error] ${domain} says:`,
162162
data.reason,
163-
[{ text: 'OK', onPress: () => void 0 }],
163+
[
164+
{
165+
text: localeString('general.ok'),
166+
onPress: () => void 0
167+
}
168+
],
164169
{ cancelable: false }
165170
);
166171
return;

views/LnurlPay/LnurlPay.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export default class LnurlPay extends React.Component<
5050
Alert.alert(
5151
localeString('views.LnurlPay.LnurlPay.invalidParams'),
5252
err.message,
53-
[{ text: 'OK', onPress: () => void 0 }],
53+
[{ text: localeString('general.ok'), onPress: () => void 0 }],
5454
{ cancelable: false }
5555
);
5656
}
@@ -96,7 +96,12 @@ export default class LnurlPay extends React.Component<
9696
Alert.alert(
9797
`[error] ${domain} says:`,
9898
data.reason,
99-
[{ text: 'OK', onPress: () => void 0 }],
99+
[
100+
{
101+
text: localeString('general.ok'),
102+
onPress: () => void 0
103+
}
104+
],
100105
{ cancelable: false }
101106
);
102107
return;
@@ -114,7 +119,12 @@ export default class LnurlPay extends React.Component<
114119
'views.LnurlPay.LnurlPay.invalidInvoice'
115120
),
116121
InvoicesStore.getPayReqError,
117-
[{ text: 'OK', onPress: () => void 0 }],
122+
[
123+
{
124+
text: localeString('general.ok'),
125+
onPress: () => void 0
126+
}
127+
],
118128
{ cancelable: false }
119129
);
120130
return;

0 commit comments

Comments
 (0)