Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit e4ab3e3

Browse files
authored
Merge pull request #725 from lightninglabs/upgrade-mobx
Upgrade mobx
2 parents 79deaeb + f2d2f07 commit e4ab3e3

File tree

15 files changed

+128
-97
lines changed

15 files changed

+128
-97
lines changed

mobile/package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mobile/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
"dependencies": {
3232
"expo": "^27.0.1",
3333
"locale-currency": "0.0.2",
34-
"mobx": "^3.6.2",
35-
"mobx-react": "^4.4.3",
34+
"mobx": "^4.5.0",
35+
"mobx-react": "^5.2.8",
3636
"node-libs-react-native": "^1.0.2",
3737
"qr-image": "^3.2.0",
3838
"react": "~16.3.2",

package-lock.json

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
"electron-updater": "^3.1.2",
3434
"grpc": "^1.15.1",
3535
"locale-currency": "0.0.2",
36-
"mobx": "^3.6.2",
37-
"mobx-react": "^4.4.3",
36+
"mobx": "^4.5.0",
37+
"mobx-react": "^5.2.8",
3838
"qr-image": "^3.2.0",
3939
"react": "^16.5.2",
4040
"react-art": "^16.5.2",

src/computed/channel.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
* @fileOverview computed values that are used in channel UI components.
33
*/
44

5-
import { computed, extendObservable } from 'mobx';
5+
import { extendObservable } from 'mobx';
66
import { toAmountLabel, toCaps } from '../helper';
77

88
const ComputedChannel = store => {
99
extendObservable(store, {
10-
computedChannels: computed(() => {
10+
get computedChannels() {
1111
const { channels, pendingChannels, settings } = store;
1212
const c = channels ? channels.slice() : [];
1313
const p = pendingChannels ? pendingChannels.slice() : [];
@@ -23,31 +23,33 @@ const ComputedChannel = store => {
2323
c.remoteBalanceLabel = toAmountLabel(c.remoteBalance, settings);
2424
});
2525
return all;
26-
}),
27-
channelBalanceOpenLabel: computed(() => {
26+
},
27+
get channelBalanceOpenLabel() {
2828
const { channels, settings } = store;
2929
const sum = (channels || [])
3030
.map(c => Number(c.localBalance))
3131
.reduce((a, b) => a + b, 0);
3232
return toAmountLabel(sum, settings);
33-
}),
34-
channelBalancePendingLabel: computed(() => {
33+
},
34+
get channelBalancePendingLabel() {
3535
const { pendingChannels, settings } = store;
3636
const sum = (pendingChannels || [])
3737
.filter(c => c.status.includes('open'))
3838
.map(c => Number(c.localBalance))
3939
.reduce((a, b) => a + b, 0);
4040
return toAmountLabel(sum, settings);
41-
}),
42-
channelBalanceClosingLabel: computed(() => {
41+
},
42+
get channelBalanceClosingLabel() {
4343
const { pendingChannels, settings } = store;
4444
const sum = (pendingChannels || [])
4545
.filter(c => !c.status.includes('open'))
4646
.map(c => Number(c.localBalance))
4747
.reduce((a, b) => a + b, 0);
4848
return toAmountLabel(sum, settings);
49-
}),
50-
showChannelAlert: computed(() => (store.channels || []).length === 0),
49+
},
50+
get showChannelAlert() {
51+
return (store.channels || []).length === 0;
52+
},
5153
});
5254
};
5355

src/computed/invoice.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
* @fileOverview computed values that are used in invoice UI components.
33
*/
44

5-
import { computed, extendObservable } from 'mobx';
5+
import { extendObservable } from 'mobx';
66
import { toLabel } from '../helper';
77

88
const ComputedInvoice = store => {
99
extendObservable(store, {
10-
invoiceAmountLabel: computed(() =>
11-
toLabel(store.invoice.amount, store.settings)
12-
),
10+
get invoiceAmountLabel() {
11+
return toLabel(store.invoice.amount, store.settings);
12+
},
1313
});
1414
};
1515

src/computed/loader-msg.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
* @fileOverview computed values that are used in loader UI components.
33
*/
44

5-
import { computed, extendObservable } from 'mobx';
5+
import { extendObservable } from 'mobx';
66

77
const ComputedLoaderMsg = store => {
88
extendObservable(store, {
9-
loadingMsg: computed(() => {
9+
get loadingMsg() {
1010
const { percentSynced: percent } = store;
1111
return getLoadingMsg(percent);
12-
}),
12+
},
1313
});
1414
};
1515

src/computed/notification.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
* @fileOverview computed values that are used in notification UI components.
33
*/
44

5-
import { computed, extendObservable } from 'mobx';
5+
import { extendObservable } from 'mobx';
66
import { toCaps, formatNumber } from '../helper';
77

88
const ComputedNotification = store => {
99
extendObservable(store, {
10-
lastNotification: computed(() => {
10+
get lastNotification() {
1111
const { notifications: nots } = store;
1212
return nots.length ? nots[nots.length - 1] : null;
13-
}),
14-
displayNotification: computed(() => {
13+
},
14+
get displayNotification() {
1515
const { lastNotification: last } = store;
1616
return last ? last.display : false;
17-
}),
18-
computedNotifications: computed(() => {
17+
},
18+
get computedNotifications() {
1919
const { notifications } = store;
2020
const all = [];
2121
notifications.forEach(n => {
@@ -31,10 +31,10 @@ const ComputedNotification = store => {
3131
n.dateTimeLabel = n.date.toLocaleString();
3232
});
3333
return all;
34-
}),
35-
notificationCountLabel: computed(() =>
36-
formatNumber(store.computedNotifications.length)
37-
),
34+
},
35+
get notificationCountLabel() {
36+
return formatNumber(store.computedNotifications.length);
37+
},
3838
});
3939
};
4040

src/computed/payment.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@
22
* @fileOverview computed values that are used in payment UI components.
33
*/
44

5-
import { computed, extendObservable } from 'mobx';
5+
import { extendObservable } from 'mobx';
66
import { toSatoshis, toAmountLabel, toLabel } from '../helper';
77

88
const ComputedPayment = store => {
99
extendObservable(store, {
10-
paymentAmountLabel: computed(() =>
11-
toLabel(store.payment.amount, store.settings)
12-
),
13-
paymentFeeLabel: computed(() => toLabel(store.payment.fee, store.settings)),
14-
paymentTotalLabel: computed(() => {
10+
get paymentAmountLabel() {
11+
return toLabel(store.payment.amount, store.settings);
12+
},
13+
get paymentFeeLabel() {
14+
return toLabel(store.payment.fee, store.settings);
15+
},
16+
get paymentTotalLabel() {
1517
const { payment, settings } = store;
1618
const satAmount = toSatoshis(payment.amount, settings);
1719
const satFee = toSatoshis(payment.fee, settings);
1820
return toAmountLabel(satAmount + satFee, settings);
19-
}),
21+
},
2022
});
2123
};
2224

src/computed/seed.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,36 @@
22
* @fileOverview computed values that are used in seed UI components.
33
*/
44

5-
import { computed, extendObservable } from 'mobx';
5+
import { extendObservable } from 'mobx';
66

77
const ComputedSeed = store => {
88
extendObservable(store, {
9-
seedVerifyIndexes: computed(() => {
9+
get seedVerifyIndexes() {
1010
const { seedMnemonic: words } = store;
1111
return words.length ? getSeedIndexes(1, words.length, 3) : [];
12-
}),
13-
seedVerifyCopy: computed(() => {
12+
},
13+
get seedVerifyCopy() {
1414
const { seedVerifyIndexes } = store;
1515
const c0 = formatOrdinal(seedVerifyIndexes[0]);
1616
const c1 = formatOrdinal(seedVerifyIndexes[1]);
1717
const c2 = formatOrdinal(seedVerifyIndexes[2]);
1818
return `Type the ${c0}, ${c1}, and ${c2} words of your recovery phrase.`;
19-
}),
20-
restoreIndexes: computed(() => [...Array(24).keys()].map(x => ++x)),
21-
restoreVerifyIndexes: computed(() => {
19+
},
20+
get restoreIndexes() {
21+
return [...Array(24).keys()].map(x => ++x);
22+
},
23+
get restoreVerifyIndexes() {
2224
const { restoreIndexes } = store;
2325
const { restoreIndex } = store.wallet;
2426
return restoreIndexes.slice(restoreIndex, restoreIndex + 3);
25-
}),
26-
restoreVerifyCopy: computed(() => {
27+
},
28+
get restoreVerifyCopy() {
2729
const { restoreVerifyIndexes } = store;
2830
const c0 = formatOrdinal(restoreVerifyIndexes[0]);
2931
const c1 = formatOrdinal(restoreVerifyIndexes[1]);
3032
const c2 = formatOrdinal(restoreVerifyIndexes[2]);
3133
return `Type the ${c0}, ${c1}, and ${c2} words of your recovery phrase.`;
32-
}),
34+
},
3335
});
3436
};
3537

0 commit comments

Comments
 (0)