Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

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

Merged
merged 2 commits into from
Jan 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions js/src/modals/UpgradeParity/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -44,8 +44,6 @@ export default class Store {

this.loadStorage();
this.checkUpgrade();

setInterval(this.checkUpgrade, CHECK_INTERVAL);
}

@computed get isVisible () {
Expand Down Expand Up @@ -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(),
Expand All @@ -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 {
Expand Down
30 changes: 16 additions & 14 deletions js/src/redux/providers/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions js/src/views/Application/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('/');
Expand All @@ -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>
Expand Down