Skip to content

Commit

Permalink
frontend: fetch state in waiting instead of parent
Browse files Browse the repository at this point in the history
Also remove unused deviceIDs prop in settings.
  • Loading branch information
benma committed Oct 27, 2018
1 parent dd5d2ec commit e9c18f2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
3 changes: 1 addition & 2 deletions frontends/web/src/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ export class App extends Component {
<ElectrumSettings
path="/settings/electrum" />
<Settings
path="/settings"
deviceIDs={deviceIDs} />
path="/settings" />
{/* Use with TypeScript: {Route<{ deviceID: string }>({ path: '/manage-backups/:deviceID', component: ManageBackups })} */}
<ManageBackups
path="/manage-backups/:deviceID"
Expand Down
9 changes: 1 addition & 8 deletions frontends/web/src/routes/device/device.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { Component, h } from 'preact';
import { route } from 'preact-router';
import { translate } from 'react-i18next';
import { apiGet } from '../../utils/request';
import { debug } from '../../utils/env';
import { apiWebsocket } from '../../utils/websocket';
import Waiting from './waiting';
import Unlock from './unlock';
Expand Down Expand Up @@ -56,7 +55,6 @@ export default class Device extends Component {
deviceRegistered: false,
deviceStatus: null,
accountsStatus: null,
testing: false,
goal: null,
success: null,
}
Expand All @@ -76,10 +74,6 @@ export default class Device extends Component {
this.onDeviceStatusChanged();
}
});

if (debug) {
apiGet('testing').then(testing => this.setState({ testing }));
}
}

componentWillUnmount() {
Expand Down Expand Up @@ -163,10 +157,9 @@ export default class Device extends Component {
accountsStatus,
goal,
success,
testing,
}) {
if (!deviceIDs.length && !accountsStatus) {
return <Waiting testing={testing} />;
return <Waiting />;
}
if (!deviceRegistered || !deviceStatus) {
return null;
Expand Down
16 changes: 14 additions & 2 deletions frontends/web/src/routes/device/waiting.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { Component, h } from 'preact';
import { translate } from 'react-i18next';
import { apiPost } from '../../utils/request';
import { apiGet, apiPost } from '../../utils/request';
import { Button } from '../../components/forms';
import { PasswordSingleInput } from '../../components/password';
import { Shift } from '../../components/icon';
Expand All @@ -30,8 +30,20 @@ import * as style from './device.css';

@translate()
export default class Waiting extends Component {
state = {
testing: false,
}

componentDidMount() {
if (debug) {
apiGet('testing').then(testing => this.setState({ testing }));
}
}


render({
t,
}, {
testing,
}) {
return (
Expand All @@ -42,7 +54,7 @@ export default class Waiting extends Component {
<div className="flex-1 flex flex-column flex-center">
<h3 style="text-align: center;">{t('welcome.insertDevice')}</h3>
<Tampered style="max-width: 400px; align-self: center;" />
<SkipForTestingButton show={debug && testing} />
<SkipForTestingButton show={testing} />
</div>
<hr />
<Footer>
Expand Down

0 comments on commit e9c18f2

Please sign in to comment.