Skip to content
Permalink
Browse files

[DDW-637] Reset error when restarting node and remove UTXO error

  • Loading branch information...
daniloprates committed May 15, 2019
1 parent 3c31138 commit 739c11a4fa68d7a7c2068d8495d6ea8323db2529
@@ -6,4 +6,5 @@ import Action from './lib/Action';
export default class NetworkStatusActions {
isSyncedAndReady: Action<any> = new Action();
tlsConfigIsReady: Action<any> = new Action();
restartNode: Action<any> = new Action();
}
@@ -453,7 +453,7 @@ export default class NetworkStatus extends Component<Props, State> {

restartNode = () => {
this.setState({ isNodeRestarting: true });
this.props.onRestartNode();
this.props.onRestartNode.trigger();
};

getClass = (isTrue: boolean) =>
@@ -1,6 +1,5 @@
// @flow
import React, { Component, Fragment } from 'react';
import { observer } from 'mobx-react';
import BigNumber from 'bignumber.js';
import classnames from 'classnames';
import { defineMessages, intlShape, FormattedHTMLMessage } from 'react-intl';
@@ -62,7 +61,6 @@ type State = {
isHoveringChart: boolean,
};

@observer
export default class WalletUtxo extends Component<Props, State> {
static contextTypes = {
intl: intlShape.isRequired,
@@ -16,6 +16,7 @@ export default class NetworkStatusDialog extends Component<Props> {
render() {
const { actions, stores } = this.props;
const { closeNetworkStatusDialog } = actions.app;
const { restartNode } = actions.networkStatus;
const { app, networkStatus } = stores;
const { openExternalLink } = app;
const {
@@ -40,7 +41,6 @@ export default class NetworkStatusDialog extends Component<Props> {
networkBlockHeight,
latestLocalBlockTimestamp,
latestNetworkBlockTimestamp,
restartNode,
isSystemTimeIgnored,
environment,
} = networkStatus;
@@ -101,6 +101,8 @@ export default class NetworkStatusStore extends Store {
setup() {
// ========== IPC CHANNELS =========== //

this.actions.networkStatus.restartNode.listen(this._restartNode);

// Request node state
this._requestCardanoState();

@@ -145,7 +147,7 @@ export default class NetworkStatusStore extends Store {
);
};

async restartNode() {
@action async _restartNode() {
try {
Logger.info('NetwortStatusStore: Requesting a restart of cardano-node');
await restartCardanoNodeChannel.send();
@@ -97,7 +97,7 @@ export default class WalletsStore extends Store {

this.registerReactions([this._updateActiveWalletOnRouteChanges]);

const { router, walletBackup, wallets, app } = this.actions;
const { router, walletBackup, wallets, app, networkStatus } = this.actions;
wallets.createWallet.listen(this._create);
wallets.deleteWallet.listen(this._deleteWallet);
wallets.sendMoney.listen(this._sendMoney);
@@ -112,6 +112,7 @@ export default class WalletsStore extends Store {
router.goToRoute.listen(this._onRouteChange);
walletBackup.finishWalletBackup.listen(this._finishCreation);
app.initAppEnvironment.listen(() => {});
networkStatus.restartNode.listen(this._updateGeneratingCertificateError);
}

_create = async (params: { name: string, spendingPassword: ?string }) => {
@@ -633,28 +634,31 @@ export default class WalletsStore extends Store {
_updateCertificateCreationState = action(
(state: boolean, error?: ?Object) => {
this.generatingCertificateInProgress = state;
if (error) {
// if (error && error.syscall && error.syscall === 'open') {
// User tries to replace a file that is open
this.generatingCertificateError = new WalletPaperWalletOpenPdfError();
} else {
this.generatingCertificateError = null;
}
this._updateGeneratingCertificateError(error);
}
);

_updateGeneratingCertificateError = action((error?: ?Object) => {
if (error && error.syscall && error.syscall === 'open') {
// User tries to replace a file that is open
this.generatingCertificateError = new WalletPaperWalletOpenPdfError();
} else {
this.generatingCertificateError = null;
}
});

@action _setCertificateTemplate = (params: { selectedTemplate: string }) => {
this.certificateTemplate = params.selectedTemplate;
this._updateCertificateStep();
};

@action _finishCertificate = () => {
this.generatingCertificateError = null;
this._updateGeneratingCertificateError();
this._closeCertificateGeneration();
};

@action _updateCertificateStep = (isBack: boolean = false) => {
this.generatingCertificateError = null;
this._updateGeneratingCertificateError();
const currrentCertificateStep = this.certificateStep || 0;
this.certificateStep = isBack
? currrentCertificateStep - 1
@@ -667,12 +671,12 @@ export default class WalletsStore extends Store {
};

@action _resetCertificateData = () => {
this.generatingCertificateError = null;
this.walletCertificatePassword = null;
this.walletCertificateAddress = null;
this.walletCertificateRecoveryPhrase = null;
this.generatingCertificateInProgress = false;
this.certificateTemplate = false;
this.certificateStep = null;
this._updateGeneratingCertificateError();
};
}

0 comments on commit 739c11a

Please sign in to comment.
You can’t perform that action at this time.