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

Commit d9c9791

Browse files
Switch from 0-100 percent range for loading network to 0-1
1 parent e9bf3c5 commit d9c9791

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

src/component/spinner.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,11 @@ SpinnerFill.propTypes = {
185185

186186
const generateArc = (percentage, radius) => {
187187
if (percentage === 0) {
188-
percentage = 1;
189-
} else if (percentage === 100) {
190-
percentage = 99.999;
188+
percentage = 0.001;
189+
} else if (percentage === 1) {
190+
percentage = 0.999;
191191
}
192-
const a = percentage * 2 * Math.PI / 100; // angle (in radian) depends on percentage
192+
const a = percentage * 2 * Math.PI; // angle (in radian) depends on percentage
193193
const r = radius; // radius of the circle
194194
var rx = r,
195195
ry = r,
@@ -198,7 +198,7 @@ const generateArc = (percentage, radius) => {
198198
sweepFlag = 1,
199199
x = r + r * Math.sin(a),
200200
y = r - r * Math.cos(a);
201-
if (percentage <= 50) {
201+
if (percentage <= 0.5) {
202202
largeArcFlag = 0;
203203
} else {
204204
largeArcFlag = 1;

src/computed/loader-msg.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ const ComputedLoaderMsg = store => {
1212
export const LOADING_COPY_START = 'Loading network...';
1313
export const LOADING_COPY_MID = 'Almost done...';
1414
export const LOADING_COPY_END = 'Just a few seconds...';
15-
export const LOADING_PERCENT_MID = 50;
16-
export const LOADING_PERCENT_END = 95;
15+
export const LOADING_PERCENT_MID = 0.5;
16+
export const LOADING_PERCENT_END = 0.95;
1717

1818
/**
1919
* Retrieve the loading message corresponding to the percent
@@ -27,8 +27,8 @@ export const getLoadingMsg = percent => {
2727
percent = 0;
2828
} else if (percent < 0) {
2929
percent = 0;
30-
} else if (percent > 100) {
31-
percent = 100;
30+
} else if (percent > 1) {
31+
percent = 1;
3232
}
3333
if (percent < LOADING_PERCENT_MID) {
3434
return LOADING_COPY_START;

src/store.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class Store {
1818
walletUnlocked: false, // Is the wallet unlocked
1919
lndReady: false, // Is lnd process running
2020
syncedToChain: false, // Is lnd synced to blockchain
21-
percentSynced: 0, // Expects 0-100 range
21+
percentSynced: 0, // Expects 0-1 range
2222
route: DEFAULT_ROUTE,
2323
blockHeight: null,
2424
balanceSatoshis: 0,

stories/component/spinner.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ storiesOf('Spinner', module)
1818
.add('Load Network Spinner', () => (
1919
<MainContent style={{ alignItems: 'flex-start', flexDirection: 'row' }}>
2020
<LoadNetworkSpinner
21-
percentage={30}
21+
percentage={0.3}
2222
msg="Loading network..."
2323
style={{ margin: 20 }}
2424
/>
2525
<LoadNetworkSpinner
26-
percentage={50}
26+
percentage={0.5}
2727
msg="Almost done..."
2828
style={{ margin: 20 }}
2929
/>
3030
<LoadNetworkSpinner
31-
percentage={100}
31+
percentage={1}
3232
msg="Just a few seconds..."
3333
style={{ margin: 20 }}
3434
/>

stories/screen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ store.pendingChannels = [...Array(6)].map((x, i) => ({
220220
status: i % 2 === 0 ? 'pending-closing' : 'pending-open',
221221
}));
222222
store.selectedChannel = store.computedChannels && store.computedChannels[0];
223-
store.percentSynced = 30;
223+
store.percentSynced = 0.3;
224224
store.seedMnemonic = [
225225
'empower',
226226
'neglect',

test/unit/computed/loader-msg.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ describe('Computed Loader Msg Unit Tests', () => {
2626
expect(store.loadingMsg, 'to equal', LOADING_COPY_START);
2727
});
2828

29-
it('should work for < 0 and > 100 percentages', () => {
29+
it('should work for < 0 and > 1 percentages', () => {
3030
store.percentSynced = -1;
3131
ComputedLoaderMsg(store);
3232
expect(store.loadingMsg, 'to equal', LOADING_COPY_START);
33-
store.percentSynced = 101;
33+
store.percentSynced = 1.01;
3434
ComputedLoaderMsg(store);
3535
expect(store.loadingMsg, 'to equal', LOADING_COPY_END);
3636
});
3737

3838
it('should work for each milestone percentage', () => {
39-
store.percentSynced = 10;
39+
store.percentSynced = 0.1;
4040
ComputedLoaderMsg(store);
4141
expect(store.loadingMsg, 'to equal', LOADING_COPY_START);
4242
store.percentSynced = LOADING_PERCENT_MID;

0 commit comments

Comments
 (0)