Poll for upgrades as part of global status (long) (#4197)

* Poll for upgrades as part of global status (long)

* Fix path
This commit is contained in:
Jaco Greeff 2017-01-18 12:44:18 +01:00 committed by Gav Wood
parent 7cab6ac263
commit c1ce65c870
3 changed files with 37 additions and 21 deletions

View File

@ -27,7 +27,7 @@ const STEP_UPDATING = 1;
const STEP_COMPLETED = 2; const STEP_COMPLETED = 2;
const STEP_ERROR = 2; const STEP_ERROR = 2;
const CHECK_INTERVAL = 1 * A_MINUTE; let instance = null;
export default class Store { export default class Store {
@observable available = null; @observable available = null;
@ -44,8 +44,6 @@ export default class Store {
this.loadStorage(); this.loadStorage();
this.checkUpgrade(); this.checkUpgrade();
setInterval(this.checkUpgrade, CHECK_INTERVAL);
} }
@computed get isVisible () { @computed get isVisible () {
@ -119,10 +117,10 @@ export default class Store {
checkUpgrade = () => { checkUpgrade = () => {
if (!this._api) { if (!this._api) {
return; return Promise.resolve(false);
} }
Promise return Promise
.all([ .all([
this._api.parity.upgradeReady(), this._api.parity.upgradeReady(),
this._api.parity.consensusCapability(), this._api.parity.consensusCapability(),
@ -134,11 +132,23 @@ export default class Store {
} }
this.setVersions(available, version, consensusCapability); this.setVersions(available, version, consensusCapability);
return true;
}) })
.catch((error) => { .catch((error) => {
console.warn('checkUpgrade', error); console.warn('checkUpgrade', error);
return false;
}); });
} }
static get (api) {
if (!instance) {
instance = new Store(api);
}
return instance;
}
} }
export { export {

View File

@ -14,29 +14,30 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
import BalancesProvider from './balances';
import { statusBlockNumber, statusCollection, statusLogs } from './statusActions';
import { isEqual } from 'lodash'; import { isEqual } from 'lodash';
import { LOG_KEYS, getLogger } from '~/config'; import { LOG_KEYS, getLogger } from '~/config';
import UpgradeStore from '~/modals/UpgradeParity/store';
import BalancesProvider from './balances';
import { statusBlockNumber, statusCollection, statusLogs } from './statusActions';
const log = getLogger(LOG_KEYS.Signer); const log = getLogger(LOG_KEYS.Signer);
let instance = null; let instance = null;
export default class Status { export default class Status {
_apiStatus = {};
_status = {};
_longStatus = {};
_minerSettings = {};
_timeoutIds = {};
_blockNumberSubscriptionId = null;
_timestamp = Date.now();
constructor (store, api) { constructor (store, api) {
this._api = api; this._api = api;
this._store = store; this._store = store;
this._upgradeStore = UpgradeStore.get(api);
this._apiStatus = {};
this._status = {};
this._longStatus = {};
this._minerSettings = {};
this._timeoutIds = {};
this._blockNumberSubscriptionId = null;
this._timestamp = Date.now();
// On connecting, stop all subscriptions // On connecting, stop all subscriptions
api.on('connecting', this.stop, this); api.on('connecting', this.stop, this);
@ -281,10 +282,11 @@ export default class Status {
this._api.parity.netChain(), this._api.parity.netChain(),
this._api.parity.netPort(), this._api.parity.netPort(),
this._api.parity.rpcSettings(), this._api.parity.rpcSettings(),
this._api.parity.enode() this._api.parity.enode(),
this._upgradeStore.checkUpgrade()
]) ])
.then(([ .then(([
netPeers, clientVersion, netVersion, defaultExtraData, netChain, netPort, rpcSettings, enode netPeers, clientVersion, netVersion, defaultExtraData, netChain, netPort, rpcSettings, enode, upgradeStatus
]) => { ]) => {
const isTest = const isTest =
netVersion === '2' || // morden netVersion === '2' || // morden

View File

@ -51,7 +51,7 @@ class Application extends Component {
} }
store = new Store(this.context.api); store = new Store(this.context.api);
upgradeStore = new UpgradeStore(this.context.api); upgradeStore = UpgradeStore.get(this.context.api);
render () { render () {
const [root] = (window.location.hash || '').replace('#/', '').split('/'); const [root] = (window.location.hash || '').replace('#/', '').split('/');
@ -65,7 +65,11 @@ class Application extends Component {
return ( return (
<div> <div>
{ isMinimized ? this.renderMinimized() : this.renderApp() } {
isMinimized
? this.renderMinimized()
: this.renderApp()
}
<Connection /> <Connection />
<ParityBar dapp={ isMinimized } /> <ParityBar dapp={ isMinimized } />
</div> </div>