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:
parent
7cab6ac263
commit
c1ce65c870
@ -27,7 +27,7 @@ const STEP_UPDATING = 1;
|
||||
const STEP_COMPLETED = 2;
|
||||
const STEP_ERROR = 2;
|
||||
|
||||
const CHECK_INTERVAL = 1 * A_MINUTE;
|
||||
let instance = null;
|
||||
|
||||
export default class Store {
|
||||
@observable available = null;
|
||||
@ -44,8 +44,6 @@ export default class Store {
|
||||
|
||||
this.loadStorage();
|
||||
this.checkUpgrade();
|
||||
|
||||
setInterval(this.checkUpgrade, CHECK_INTERVAL);
|
||||
}
|
||||
|
||||
@computed get isVisible () {
|
||||
@ -119,10 +117,10 @@ export default class Store {
|
||||
|
||||
checkUpgrade = () => {
|
||||
if (!this._api) {
|
||||
return;
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
|
||||
Promise
|
||||
return Promise
|
||||
.all([
|
||||
this._api.parity.upgradeReady(),
|
||||
this._api.parity.consensusCapability(),
|
||||
@ -134,11 +132,23 @@ export default class Store {
|
||||
}
|
||||
|
||||
this.setVersions(available, version, consensusCapability);
|
||||
|
||||
return true;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.warn('checkUpgrade', error);
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
static get (api) {
|
||||
if (!instance) {
|
||||
instance = new Store(api);
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
|
@ -14,29 +14,30 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// 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 { 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);
|
||||
let instance = null;
|
||||
|
||||
export default class Status {
|
||||
_apiStatus = {};
|
||||
_status = {};
|
||||
_longStatus = {};
|
||||
_minerSettings = {};
|
||||
_timeoutIds = {};
|
||||
_blockNumberSubscriptionId = null;
|
||||
_timestamp = Date.now();
|
||||
|
||||
constructor (store, api) {
|
||||
this._api = api;
|
||||
this._store = store;
|
||||
|
||||
this._apiStatus = {};
|
||||
this._status = {};
|
||||
this._longStatus = {};
|
||||
this._minerSettings = {};
|
||||
|
||||
this._timeoutIds = {};
|
||||
this._blockNumberSubscriptionId = null;
|
||||
|
||||
this._timestamp = Date.now();
|
||||
this._upgradeStore = UpgradeStore.get(api);
|
||||
|
||||
// On connecting, stop all subscriptions
|
||||
api.on('connecting', this.stop, this);
|
||||
@ -281,10 +282,11 @@ export default class Status {
|
||||
this._api.parity.netChain(),
|
||||
this._api.parity.netPort(),
|
||||
this._api.parity.rpcSettings(),
|
||||
this._api.parity.enode()
|
||||
this._api.parity.enode(),
|
||||
this._upgradeStore.checkUpgrade()
|
||||
])
|
||||
.then(([
|
||||
netPeers, clientVersion, netVersion, defaultExtraData, netChain, netPort, rpcSettings, enode
|
||||
netPeers, clientVersion, netVersion, defaultExtraData, netChain, netPort, rpcSettings, enode, upgradeStatus
|
||||
]) => {
|
||||
const isTest =
|
||||
netVersion === '2' || // morden
|
||||
|
@ -51,7 +51,7 @@ class Application extends Component {
|
||||
}
|
||||
|
||||
store = new Store(this.context.api);
|
||||
upgradeStore = new UpgradeStore(this.context.api);
|
||||
upgradeStore = UpgradeStore.get(this.context.api);
|
||||
|
||||
render () {
|
||||
const [root] = (window.location.hash || '').replace('#/', '').split('/');
|
||||
@ -65,7 +65,11 @@ class Application extends Component {
|
||||
|
||||
return (
|
||||
<div>
|
||||
{ isMinimized ? this.renderMinimized() : this.renderApp() }
|
||||
{
|
||||
isMinimized
|
||||
? this.renderMinimized()
|
||||
: this.renderApp()
|
||||
}
|
||||
<Connection />
|
||||
<ParityBar dapp={ isMinimized } />
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user