feat(loading-screen): add status message in loading screen
This commit is contained in:
parent
91f32e1a8d
commit
9886b22a4a
|
@ -14,7 +14,7 @@ describe('<LoadingScreen />', () => {
|
|||
test('should render status pill correctly', () => {
|
||||
const { queryByTestId } = render(
|
||||
<ThemeProvider theme={appTheme}>
|
||||
<LoadingScreen progress={83.0} />
|
||||
<LoadingScreen progress={83.0} message='ZEC Wallet Starting' />
|
||||
</ThemeProvider>,
|
||||
);
|
||||
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
import React, { PureComponent } from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { Transition, animated } from 'react-spring';
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
import { ipcRenderer } from 'electron';
|
||||
|
||||
import CircleProgressComponent from 'react-circle';
|
||||
import { TextComponent } from './text';
|
||||
|
@ -41,35 +39,27 @@ const Logo = styled.img`
|
|||
|
||||
type Props = {
|
||||
progress: number,
|
||||
message: string,
|
||||
};
|
||||
|
||||
type State = {
|
||||
start: boolean,
|
||||
message: string,
|
||||
};
|
||||
|
||||
const TIME_DELAY_ANIM = 100;
|
||||
|
||||
export class LoadingScreen extends PureComponent<Props, State> {
|
||||
state = { start: false, message: 'ZEC Wallet Starting' };
|
||||
state = { start: false };
|
||||
|
||||
componentDidMount() {
|
||||
setTimeout(() => {
|
||||
this.setState(() => ({ start: true }));
|
||||
}, TIME_DELAY_ANIM);
|
||||
|
||||
ipcRenderer.on('zcashd-params-download', (event: Object, message: string) => {
|
||||
this.setState(() => ({ message }));
|
||||
});
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
ipcRenderer.removeAllListeners('zcashd-log');
|
||||
}
|
||||
|
||||
render() {
|
||||
const { start, message } = this.state;
|
||||
const { progress } = this.props;
|
||||
const { start } = this.state;
|
||||
const { progress, message } = this.props;
|
||||
|
||||
return (
|
||||
<Wrapper data-testid='LoadingScreen'>
|
||||
|
|
|
@ -11,6 +11,7 @@ type Props = {};
|
|||
type State = {
|
||||
isRunning: boolean,
|
||||
progress: number,
|
||||
message: string,
|
||||
};
|
||||
|
||||
/* eslint-disable max-len */
|
||||
|
@ -22,6 +23,7 @@ export const withDaemonStatusCheck = <PassedProps: {}>(
|
|||
state = {
|
||||
isRunning: false,
|
||||
progress: 0,
|
||||
message: 'ZEC Wallet Starting',
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
|
@ -53,21 +55,23 @@ export const withDaemonStatusCheck = <PassedProps: {}>(
|
|||
}
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
.catch((error) => {
|
||||
const statusMessage = error.message === 'Something went wrong' ? 'ZEC Wallet Starting' : error.message;
|
||||
|
||||
this.setState((state) => {
|
||||
const newProgress = state.progress > 70 ? state.progress + 2.5 : state.progress + 5;
|
||||
return { progress: newProgress > 95 ? 95 : newProgress };
|
||||
return { progress: newProgress > 95 ? 95 : newProgress, message: statusMessage };
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
render() {
|
||||
const { isRunning, progress } = this.state;
|
||||
const { isRunning, progress, message } = this.state;
|
||||
|
||||
if (isRunning) {
|
||||
return <WrappedComponent {...this.props} {...this.state} />;
|
||||
}
|
||||
|
||||
return <LoadingScreen progress={progress} />;
|
||||
return <LoadingScreen progress={progress} message={message} />;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue