diff --git a/packages/fether-react/package.json b/packages/fether-react/package.json index d4709fd510dd37a44dc03dde0f02bd8704e49027..0e8858d847ecae77c49d9720244ef37e976892e1 100644 --- a/packages/fether-react/package.json +++ b/packages/fether-react/package.json @@ -35,7 +35,7 @@ }, "dependencies": { "@parity/api": "^2.1.22", - "@parity/light.js": "https://github.com/parity-js/light.js#458d9318ef16bc583375d7a5cd414e2939d6ecfd", + "@parity/light.js": "https://github.com/parity-js/light.js#f2e4648db57a97380ad374d7cd15342f44a5ade1", "@parity/shared": "^3.0.2", "bignumber.js": "^4.1.0", "debounce-promise": "^3.1.0", diff --git a/packages/fether-react/src/Health/Health.js b/packages/fether-react/src/Health/Health.js index 02d6c6d8a6c2e0ed971c0fd0e395042cef3fb9db..fc2f584e63645f508911f69261076f30254d8935 100644 --- a/packages/fether-react/src/Health/Health.js +++ b/packages/fether-react/src/Health/Health.js @@ -60,8 +60,8 @@ class Health extends Component { return `Downloading... (${payload.percentage}%)`; case STATUS.GOOD: return 'Synced'; - case STATUS.NOINTERNET: - return 'No internet'; + case STATUS.NOPEERS: + return 'Not connected to any peers'; case STATUS.RUNNING: return 'Running...'; case STATUS.SYNCING: diff --git a/packages/fether-react/src/Overlay/Overlay.js b/packages/fether-react/src/Overlay/Overlay.js index 93f9ee5028820a9dabc91beb7db955ef7b602da9..bc8407a69a4153ec7f4a15e4de6baef5bfc8664a 100644 --- a/packages/fether-react/src/Overlay/Overlay.js +++ b/packages/fether-react/src/Overlay/Overlay.js @@ -74,7 +74,7 @@ class Overlays extends Component { switch (status) { case STATUS.CLOCKNOTSYNC: - return `Mac: System Preferences -> Date & Time -> Uncheck and recheck + return `Mac: System Preferences -> Date & Time -> Uncheck and recheck "Set date and time automatically" Windows: Control Panel -> "Clock, Language, and Region" -> "Date and Time" -> Uncheck and recheck "Set date and time automatically"`; @@ -83,7 +83,7 @@ class Overlays extends Component { return payload && payload.percentage && payload.percentage.gt(0) ? `${payload.percentage.toFixed(0)}%` : ''; - case STATUS.NOINTERNET: + case STATUS.NOPEERS: return 'Getting some more peers...'; default: return ''; @@ -102,7 +102,7 @@ class Overlays extends Component { return 'Your clock is not sync'; case STATUS.DOWNLOADING: return 'Downloading Parity...'; - case STATUS.NOINTERNET: + case STATUS.NOPEERS: return 'Bad connectivity'; case STATUS.RUNNING: return 'Connecting to the node...'; diff --git a/packages/fether-react/src/assets/sass/components/_alert-screen.scss b/packages/fether-react/src/assets/sass/components/_alert-screen.scss index b4953dc97b335164a2908f392f14d7b3c874bad3..737a136ea168c5a356947ab83b59290d90884053 100644 --- a/packages/fether-react/src/assets/sass/components/_alert-screen.scss +++ b/packages/fether-react/src/assets/sass/components/_alert-screen.scss @@ -22,6 +22,7 @@ .alert-screen_text { margin-top: 1rem; text-align: center; + white-space: pre-line; h1, h2, big, diff --git a/packages/fether-react/src/stores/healthStore.js b/packages/fether-react/src/stores/healthStore.js index 435b8ffe9610c23560ba6e22ce1d51d3765d1e71..55206bb593465f7ae1754c8750277215b8b0f619 100644 --- a/packages/fether-react/src/stores/healthStore.js +++ b/packages/fether-react/src/stores/healthStore.js @@ -7,7 +7,7 @@ import { action, computed, observable } from 'mobx'; import BigNumber from 'bignumber.js'; import isElectron from 'is-electron'; -import { nodeHealth$, syncing$ } from '@parity/light.js'; +import { peerCount$, syncing$ } from '@parity/light.js'; import Debug from '../utils/debug'; import parityStore from './parityStore'; @@ -18,23 +18,22 @@ const electron = isElectron() ? window.require('electron') : null; // List here all possible states of our health store. Each state can have a // payload. export const STATUS = { - CANTCONNECT: 'CANTCONNECT', // Can't connect to Parity's api - CLOCKNOTSYNC: 'CLOCKNOTSYNC', // Local clock is not sync - DOWNLOADING: 'DOWNLOADING', // Currently downloading Parity - GOOD: 'GOOD', // Everything's fine - NOINTERNET: 'NOINTERNET', // No network connection - OTHER: 'OTHER', // Unknown state, might have a payload - RUNNING: 'RUNNING', // Parity is running (only checked at startup) - SYNCING: 'SYNCING' // Obvious + CANTCONNECT: Symbol('CANTCONNECT'), // Can't connect to Parity's api + CLOCKNOTSYNC: Symbol('CLOCKNOTSYNC'), // Local clock is not sync + DOWNLOADING: Symbol('DOWNLOADING'), // Currently downloading Parity + GOOD: Symbol('GOOD'), // Everything's fine + NOPEERS: Symbol('NOPEERS'), // Not connected to any peers + RUNNING: Symbol('RUNNING'), // Parity is running (only checked at startup) + SYNCING: Symbol('SYNCING') // Obvious }; export class HealthStore { - @observable nodeHealth; + @observable peerCount; @observable syncing; @observable clockSync; constructor () { - nodeHealth$().subscribe(this.setNodeHealth); + peerCount$(({withoutLoading: true})).subscribe(this.setPeerCount); syncing$().subscribe(this.setSyncing); if (!electron) { @@ -80,9 +79,7 @@ export class HealthStore { // Check if we get responses from the WS server if ( - !parityStore.isApiConnected || - !this.nodeHealth || - !Object.keys(this.nodeHealth).length + !parityStore.isApiConnected ) { return { status: STATUS.CANTCONNECT @@ -105,64 +102,22 @@ export class HealthStore { }; } - // Find out if there are bad statuses - const bad = Object.values(this.nodeHealth) - .filter(x => x) - .map(({ status }) => status) - .find(s => s === 'bad'); - // Find out if there are needsAttention statuses - const needsAttention = Object.keys(this.nodeHealth) - .filter(key => key !== 'time') - .map(key => this.nodeHealth[key]) - .filter(x => x) - .map(({ status }) => status) - .find(s => s === 'needsattention'); - - if (!bad && !needsAttention) { - return { - status: STATUS.GOOD - }; - } - - // Now we have a bad or a needsattention message - - // Get all non-empty messages from all statuses - const details = Object.values(this.nodeHealth) - .map(({ message }) => message) - .filter(x => x); - - // If status is bad or needsattention, there should be an associated - // message. Just in case, we do an additional test. - if (!details || !details.length) { - return { status: STATUS.OTHER }; - } - - const message = details[0]; - - if ( - message === - "Your node is still syncing, the values you see might be outdated. Wait until it's fully synced." - ) { - return { status: STATUS.SYNCING }; - } - - if ( - message === - 'You are not connected to any peers. There is most likely some network issue. Fix connectivity.' - ) { - return { status: STATUS.NOINTERNET, payload: message }; + if (this.clockSync && !this.clockSync.isClockSync) { + return { status: STATUS.CLOCKNOTSYNC }; } - if (this.clockSync && this.clockSync.isClockSync) { - return { status: STATUS.CLOCKNOTSYNC, payload: message }; + if (this.peerCount && this.peerCount.eq(0)) { + return { status: STATUS.NOPEERS }; } - return { status: STATUS.OTHER, payload: message }; + return { + status: STATUS.GOOD + }; } @action - setNodeHealth = nodeHealth => { - this.nodeHealth = nodeHealth; + setPeerCount = peerCount => { + this.peerCount = peerCount; }; @action diff --git a/packages/light-hoc/package.json b/packages/light-hoc/package.json index 23fd90948d2000417021aa6bf2267a68ac1dac97..dbdf97766d567b2e537a8385cc4bb1375e64940e 100644 --- a/packages/light-hoc/package.json +++ b/packages/light-hoc/package.json @@ -31,7 +31,7 @@ "start": "yarn build --watch" }, "peerDependencies": { - "@parity/light.js": "https://github.com/parity-js/light.js#458d9318ef16bc583375d7a5cd414e2939d6ecfd", + "@parity/light.js": "https://github.com/parity-js/light.js#f2e4648db57a97380ad374d7cd15342f44a5ade1", "react": "^16.4.0" }, "devDependencies": { diff --git a/yarn.lock b/yarn.lock index 5d2abf810597c190fb09c43286358c0e4ca5f6be..29cd7fb395710f4e8a5bc2aefd6147046d171e16 100644 --- a/yarn.lock +++ b/yarn.lock @@ -977,9 +977,9 @@ u2f-api "0.0.9" u2f-api-polyfill "0.4.3" -"@parity/light.js@https://github.com/parity-js/light.js#458d9318ef16bc583375d7a5cd414e2939d6ecfd": +"@parity/light.js@https://github.com/parity-js/light.js#f2e4648db57a97380ad374d7cd15342f44a5ade1": version "1.0.0" - resolved "https://github.com/parity-js/light.js#458d9318ef16bc583375d7a5cd414e2939d6ecfd" + resolved "https://github.com/parity-js/light.js#f2e4648db57a97380ad374d7cd15342f44a5ade1" dependencies: "@parity/api" "^2.1.23" json-prune "^1.1.0"