Browse Source

skip tx history re-render if data is the same

all-modes
pbca26 8 years ago
parent
commit
27f0521822
  1. 19
      react/src/components/dashboard/coinTile/coinTileItem.js
  2. 34
      react/src/components/dashboard/walletsData/walletsData.js
  3. 4
      react/src/components/dashboard/walletsProgress/walletsProgress.js
  4. 3
      react/src/components/dashboard/walletsTxInfo/walletsTxInfo.render.js
  5. 7
      react/src/util/sort.js

19
react/src/components/dashboard/coinTile/coinTileItem.js

@ -25,10 +25,9 @@ import Config from '../../../config';
import CoinTileItemRender from './coinTileItem.render';
const BASILISK_CACHE_UPDATE_TIMEOUT = 240000;
const IGUNA_ACTIVE_HANDLE_TIMEOUT = 30000;
const IGUNA_ACTIVE_HANDLE_TIMEOUT_KMD_NATIVE = 30000;
const IGUNA_ACTIVE_HANDLE_TIMEOUT = 3000;
const IGUNA_ACTIVE_HANDLE_TIMEOUT_KMD_NATIVE = 15000;
const NATIVE_MIN_SYNC_PERCENTAGE_THRESHOLD = 90;
let coinInitDataFetchInterval;
class CoinTileItem extends React.Component {
constructor(props) {
@ -108,20 +107,6 @@ class CoinTileItem extends React.Component {
dashboardChangeActiveCoin(coin, mode) {
if (coin !== this.props.ActiveCoin.coin) {
if (!this.props.ActiveCoin.coins[this.props.ActiveCoin.coin]) {
coinInitDataFetchInterval = setInterval(() => {
this.dispatchCoinActions(coin, mode);
if ((mode === 'native' || mode === 'full') && this.props.Dashboard.progress) {
clearInterval(coinInitDataFetchInterval);
}
if (mode === 'basilisk' && (this.props.ActiveCoin.txhistory && this.props.ActiveCoin.txhistory !== 'loading') && this.props.Dashboard.activeHandle[this.props.ActiveCoin.coin] && JSON.parse(sessionStorage.getItem('IguanaActiveAccount'))[this.props.ActiveCoin.coin]) {
clearInterval(coinInitDataFetchInterval);
}
}, 500);
}
Store.dispatch(
stopInterval(
'sync',

34
react/src/components/dashboard/walletsData/walletsData.js

@ -49,6 +49,7 @@ class WalletsData extends React.Component {
currentStackLength: 0,
totalStackLength: 0,
useCache: true,
coin: null,
};
this.updateInput = this.updateInput.bind(this);
this.toggleBasiliskActionsMenu = this.toggleBasiliskActionsMenu.bind(this);
@ -278,9 +279,16 @@ class WalletsData extends React.Component {
this.state.activePage * this.state.itemsPerPage
);
stateObj = Object.assign(stateObj, {
itemsList: historyToSplit,
});
if (!this.state.itemsList || (this.state.coin && this.state.coin !== this.props.ActiveCoin.coin) || (historyToSplit &&
historyToSplit.length &&
this.state.itemsList &&
this.state.itemsList.length &&
historyToSplit[0].txid !== this.state.itemsList[0].txid &&
historyToSplit[historyToSplit.length - 1].txid !== this.state.itemsList[this.state.itemsList.length - 1].txid)) {
stateObj = Object.assign(stateObj, {
itemsList: historyToSplit,
});
}
}
}
@ -307,12 +315,24 @@ class WalletsData extends React.Component {
this.state.activePage * this.state.itemsPerPage
);
stateObj = Object.assign(stateObj, {
itemsList: historyToSplit,
});
if (!this.state.itemsList || (this.state.coin && this.state.coin !== this.props.ActiveCoin.coin) || (historyToSplit &&
historyToSplit.length &&
this.state.itemsList &&
this.state.itemsList.length &&
historyToSplit[0].txid !== this.state.itemsList[0].txid &&
historyToSplit[historyToSplit.length - 1].txid !== this.state.itemsList[this.state.itemsList.length - 1].txid)) {
stateObj = Object.assign(stateObj, {
itemsList: historyToSplit,
});
}
}
this.setState(Object.assign({}, this.state, stateObj));
stateObj = Object.assign(stateObj, {
coin: this.props.ActiveCoin.coin,
});
if (Object.keys(stateObj).length) {
this.setState(Object.assign({}, this.state, stateObj));
}
}
}

4
react/src/components/dashboard/walletsProgress/walletsProgress.js

@ -93,7 +93,7 @@ class WalletsProgress extends React.Component {
if (_progress &&
_progress[1]) {
return SyncPercentageRender.call(this, _progress[1].toFixed(2));
return SyncPercentageRender.call(this, _progress[1] === 1000 ? 100 : _progress[1].toFixed(2));
} else {
return LoadingBlocksRender.call(this);
}
@ -113,7 +113,7 @@ class WalletsProgress extends React.Component {
if (this.props.Dashboard.progress &&
this.props.Dashboard.progress.blocks) {
const syncPercentage = (parseFloat(parseInt(this.props.Dashboard.progress.blocks, 10) * 100 / parseInt(this.props.Dashboard.progress.longestchain, 10)).toFixed(2) + '%').replace('NaN', 0);
return SyncPercentageRender.call(this, syncPercentage);
return SyncPercentageRender.call(this, syncPercentage === 1000 ? 100 : syncPercentage);
}
return LoadingBlocksRender.call(this);

3
react/src/components/dashboard/walletsTxInfo/walletsTxInfo.render.js

@ -20,7 +20,6 @@ const WalletsTxInfoRender = function(txInfo) {
<i className="icon md-balance-wallet"></i>TxID Info
</a>
</li>
{ this.isNativeMode() &&
<li className={ this.state.activeTab === 1 ? 'hide active' : 'hide' }>
<a onClick={ () => this.openTab(1) }>
@ -28,7 +27,6 @@ const WalletsTxInfoRender = function(txInfo) {
</a>
</li>
}
{ this.isNativeMode() &&
<li className={ this.state.activeTab === 2 ? 'hide active' : 'hide' }>
<a onClick={ () => this.openTab(2) }>
@ -36,7 +34,6 @@ const WalletsTxInfoRender = function(txInfo) {
</a>
</li>
}
<li className={ this.state.activeTab === 3 ? 'active' : '' }>
<a onClick={ () => this.openTab(3) }>
<i className="icon wb-file"></i>Raw info

7
react/src/util/sort.js

@ -1,9 +1,10 @@
export function sortByDate(data) {
return data.sort(function(a, b) {
if (a.txid === b.txid) {
return 1;
} else {
if (a.confirmations &&
b.confirmations) {
return a.confirmations - b.confirmations;
} else {
return 1;
}
});
}
Loading…
Cancel
Save