Skip to content

Commit

Permalink
upgrade hsd to 2.4.0; add warning message when node is migrating
Browse files Browse the repository at this point in the history
  • Loading branch information
chikeichan committed Apr 3, 2021
1 parent 5023b97 commit fdbbb84
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 55 deletions.
5 changes: 5 additions & 0 deletions app/background/node/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export class NodeService extends EventEmitter {
}

async startNode() {
await put('hsd-2.4.0-migrate', false);
if (this.hsd) {
return;
}
Expand Down Expand Up @@ -103,6 +104,10 @@ export class NodeService extends EventEmitter {
await hsd.connect();
await hsd.startSync();

if (!(await get('hsd-2.4.0-migrate'))) {
await put('hsd-2.4.0-migrate', true);
}

this.hsd = hsd;
}

Expand Down
5 changes: 3 additions & 2 deletions app/components/Alert/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ export default class Alert extends Component {
]).isRequired,
message: PropTypes.string,
children: PropTypes.node,
style: PropTypes.object,
};

render() {
const { message, type, children} = this.props;
const { message, type, children, style} = this.props;

if (!message && !children) {
return null;
Expand All @@ -23,7 +24,7 @@ export default class Alert extends Component {
const name = `alert alert--${type}`;

return (
<div className={name}>
<div className={name} style={style}>
{children || message}
</div>
);
Expand Down
125 changes: 76 additions & 49 deletions app/components/SplashScreen/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React, { Component } from 'react';
import Proptype from 'prop-types';
import BobLogo from '../../assets/images/bob-logo-circle.svg';
import Spinner from '../../assets/images/brick-loader.svg';
import dbClient from "../../utils/dbClient";
import Alert from "../Alert";

export default class SplashScreen extends Component {
static propTypes = {
Expand All @@ -12,65 +14,90 @@ export default class SplashScreen extends Component {
error: '',
};

render() {
const {error} = this.props;

const wrapperStyle = {
display: 'flex',
flexFlow: 'column nowrap',
justifyContent: 'center',
alignItems: 'center',
height: '100vh',
};

const logoWrapperStyle = {
display: 'flex',
flexFlow: 'row nowrap',
justifyContent: 'center',
alignItems: 'baseline',
margin: '3rem 0',
};

const bobLogoStyle = {
backgroundImage: `url(${BobLogo})`,
height: '75px',
width: '75px',
backgroundSize: 'contain',
backgroundPosition: 'center',
backgroundRepeat: 'no-repeat',
animation: '0.5s ease-in-out',
};
state = {
hasMigrated240: false,
};

const spinnerStyle = {
backgroundImage: `url(${Spinner})`,
marginBottom: '15px',
height: '1.5rem',
width: '1.5rem',
backgroundSize: 'cover',
backgroundPosition: 'center',
animation: '0.5s ease-in-out',
};
async componentWillMount() {
const hasMigrated240 = await dbClient.get('hsd-2.4.0-migrate');
this.setState({ hasMigrated240 });
}

const textStyles = {
fontSize: '1rem',
lineHeight: '1rem * 1.4',
color: '#909095',
maxWidth: '300px',
};
render() {
const {error} = this.props;

return (
<div style={wrapperStyle}>
<div style={logoWrapperStyle}>
<div style={bobLogoStyle} />
</div>
{error ? <div style={textStyles}> {error} </div> : (
<React.Fragment>
<div style={spinnerStyle} />
<div style={textStyles}>Loading node...</div>
</React.Fragment>
)
{
error
? <div style={textStyles}> {error} </div>
: (
<React.Fragment>
<div style={spinnerStyle} />
<div style={textStyles}>Loading node...</div>
{
!this.state.hasMigrated240 && (
<Alert type="warning" style={alertStyle}>
Migration in progress. This will take several minutes. PLEASE DO NOT CLOSE BOB!
</Alert>
)
}
</React.Fragment>
)
}
</div>
);
}
}

const wrapperStyle = {
display: 'flex',
flexFlow: 'column nowrap',
justifyContent: 'center',
alignItems: 'center',
height: '100vh',
};

const logoWrapperStyle = {
display: 'flex',
flexFlow: 'row nowrap',
justifyContent: 'center',
alignItems: 'baseline',
margin: '3rem 0',
};

const bobLogoStyle = {
backgroundImage: `url(${BobLogo})`,
height: '75px',
width: '75px',
backgroundSize: 'contain',
backgroundPosition: 'center',
backgroundRepeat: 'no-repeat',
animation: '0.5s ease-in-out',
};

const spinnerStyle = {
backgroundImage: `url(${Spinner})`,
marginBottom: '15px',
height: '1.5rem',
width: '1.5rem',
backgroundSize: 'cover',
backgroundPosition: 'center',
animation: '0.5s ease-in-out',
};

const textStyles = {
fontSize: '1rem',
lineHeight: '1rem * 1.4',
color: '#909095',
maxWidth: '300px',
};

const alertStyle = {
marginTop: '1rem',
width: '24rem',
textAlign: 'center',
};
28 changes: 25 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
"electron-updater": "4.1.2",
"history": "4.7.2",
"hs-client": "https://github.com/handshake-org/hs-client.git",
"hsd": "https://github.com/handshake-org/hsd/tarball/b66085a",
"hsd": "https://github.com/handshake-org/hsd/tarball/375ef41",
"isomorphic-fetch": "^2.2.1",
"jsonschema": "^1.4.0",
"lodash.isequal": "4.5.0",
Expand Down

0 comments on commit fdbbb84

Please sign in to comment.