import React from 'react'; import { translate } from '../../../translate/translate'; import { connect } from 'react-redux'; import Config from '../../../config'; import { getPeersList, checkForUpdateUIPromise, } from '../../../actions/actionCreators'; let updateProgressBar = { patch: -1, }; class AppUpdatePanel extends React.Component { constructor() { super(); this.state = { updatePatch: null, updateLog: [], }; this._checkForUpdateUIPromise = this._checkForUpdateUIPromise.bind(this); this._updateUIPromise = this._updateUIPromise.bind(this); this.checkNodes = this.checkNodes.bind(this); } checkNodes() { if (this.state.getPeersCoin) { Store.dispatch(getPeersList(this.state.getPeersCoin.split('|')[0])); } } _updateUIPromise() { updateProgressBar.patch = 0; let _updateLog = []; _updateLog.push(`${translate('INDEX.DOWNLOADING_UI_UPDATE')}...`); this.setState(Object.assign({}, this.state, { updateLog: _updateLog, })); updateUIPromise(); } _checkForUpdateUIPromise() { let _updateLog = []; _updateLog.push(translate('INDEX.CHECKING_UI_UPDATE')); this.setState(Object.assign({}, this.state, { updateLog: _updateLog, })); checkForUpdateUIPromise() .then((res) => { let _updateLog = this.state.updateLog; _updateLog.push(res.result === 'update' ? (`${translate('INDEX.NEW_UI_UPDATE')} ${res.version.remote}`) : translate('INDEX.YOU_HAVE_LATEST_UI')); this.setState(Object.assign({}, this.state, { updatePatch: res.result === 'update' ? true : false, updateLog: _updateLog, })); }); } renderUpdateStatus() { let items = []; let patchProgressBar = null; const _updateLogLength = this.state.updateLog.length; for (let i = 0; i < _updateLogLength; i++) { items.push(