Browse Source

Merge pull request #162 from SuperNETorg/cleanup

sorting fix
all-modes
pbca26 8 years ago
committed by GitHub
parent
commit
08a840ebc5
  1. 4
      react/src/components/dashboard/coinTile/coinTileItem.js
  2. 2
      react/src/components/dashboard/settings/settings.render.js
  3. 59
      react/src/components/dashboard/walletsData/walletsData.js
  4. 4
      react/src/components/dashboard/walletsData/walletsData.render.js
  5. 5
      react/src/components/dashboard/walletsProgress/walletsProgress.js
  6. 2
      react/src/components/dashboard/walletsProgress/walletsProgress.render.js
  7. 3
      react/src/translate/en.js
  8. 13
      react/src/util/sort.js

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

@ -108,7 +108,9 @@ class CoinTileItem extends React.Component {
dashboardChangeActiveCoin(coin, mode) { dashboardChangeActiveCoin(coin, mode) {
if (coin !== this.props.ActiveCoin.coin) { if (coin !== this.props.ActiveCoin.coin) {
Store.dispatch(dashboardChangeActiveCoin(coin, mode)); Store.dispatch(dashboardChangeActiveCoin(coin, mode));
this.dispatchCoinActions(coin, mode); // triggers fetch coin data from store if available setTimeout(() => {
this.dispatchCoinActions(coin, mode);
}, 100);
Store.dispatch( Store.dispatch(
stopInterval( stopInterval(

2
react/src/components/dashboard/settings/settings.render.js

@ -77,7 +77,7 @@ export const AppInfoTabRender = function() {
{ translate('SETTINGS.NAME') }: { this.props.Settings.appInfo.releaseInfo.name } { translate('SETTINGS.NAME') }: { this.props.Settings.appInfo.releaseInfo.name }
</div> </div>
<div> <div>
{ translate('SETTINGS.VERSION') }: { this.props.Settings.appInfo.releaseInfo.version } { translate('SETTINGS.VERSION') }: { `${this.props.Settings.appInfo.releaseInfo.version.replace('version=', '')}-beta` }
</div> </div>
<div> <div>
{ translate('SETTINGS.APP_SESSION') }: { this.props.Settings.appInfo.appSession } { translate('SETTINGS.APP_SESSION') }: { this.props.Settings.appInfo.appSession }

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

@ -50,6 +50,7 @@ class WalletsData extends React.Component {
totalStackLength: 0, totalStackLength: 0,
useCache: true, useCache: true,
coin: null, coin: null,
txhistory: null,
}; };
this.updateInput = this.updateInput.bind(this); this.updateInput = this.updateInput.bind(this);
this.toggleBasiliskActionsMenu = this.toggleBasiliskActionsMenu.bind(this); this.toggleBasiliskActionsMenu = this.toggleBasiliskActionsMenu.bind(this);
@ -152,7 +153,9 @@ class WalletsData extends React.Component {
Store.dispatch(basiliskRefresh(false)); Store.dispatch(basiliskRefresh(false));
} }
this.setState(Object.assign({}, this.state, stateObj)); if (Object.keys(stateObj).length) {
this.setState(Object.assign({}, this.state, stateObj));
}
} }
} }
@ -238,7 +241,7 @@ class WalletsData extends React.Component {
} }
updateInput(e) { updateInput(e) {
let historyToSplit = sortByDate(this.props.ActiveCoin.txhistory); let historyToSplit = sortByDate(this.props.ActiveCoin.txhistory, this.props.ActiveCoin.mode);
historyToSplit = historyToSplit.slice(0, e.target.value); historyToSplit = historyToSplit.slice(0, e.target.value);
this.setState({ this.setState({
@ -252,6 +255,16 @@ class WalletsData extends React.Component {
Store.dispatch(toggleDashboardTxInfoModal(display, txIndex)); Store.dispatch(toggleDashboardTxInfoModal(display, txIndex));
} }
indexTxHistory(txhistoryArr) {
if (txhistoryArr.length > 1) {
for (let i = 0; i < txhistoryArr.length; i++) {
this.props.ActiveCoin.txhistory[i]['index'] = i + 1;
}
}
return this.props.ActiveCoin.txhistory;
}
componentWillReceiveProps(props) { componentWillReceiveProps(props) {
let historyToSplit; let historyToSplit;
let stateObj = {}; let stateObj = {};
@ -270,26 +283,21 @@ class WalletsData extends React.Component {
this.props.ActiveCoin.txhistory !== 'loading' && this.props.ActiveCoin.txhistory !== 'loading' &&
this.props.ActiveCoin.txhistory !== 'no data' && this.props.ActiveCoin.txhistory !== 'no data' &&
this.props.ActiveCoin.txhistory.length) { this.props.ActiveCoin.txhistory.length) {
if (!this.state.itemsList ||
(this.state.itemsList && !this.state.itemsList.length) || historyToSplit = sortByDate(this.indexTxHistory(this.props.ActiveCoin.txhistory), this.props.ActiveCoin.mode === 'basilisk' ? 'index' : 'confirmations');
(props.ActiveCoin.txhistory !== this.props.ActiveCoin.txhistory)) {
historyToSplit = sortByDate(this.props.ActiveCoin.txhistory);
historyToSplit = historyToSplit.slice( historyToSplit = historyToSplit.slice(
(this.state.activePage - 1) * this.state.itemsPerPage, (this.state.activePage - 1) * this.state.itemsPerPage,
this.state.activePage * this.state.itemsPerPage this.state.activePage * this.state.itemsPerPage
); );
if (!this.state.itemsList || (this.state.coin && this.state.coin !== this.props.ActiveCoin.coin) || (historyToSplit && if (!this.state.itemsList || (this.state.coin && this.state.coin !== this.props.ActiveCoin.coin) || (
historyToSplit.length && JSON.stringify(this.props.ActiveCoin.txhistory) !== JSON.stringify(this.state.txhistory))) {
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, { stateObj = Object.assign(stateObj, {
itemsList: historyToSplit, itemsList: historyToSplit,
txhistory: this.props.ActiveCoin.txhistory,
}); });
} }
}
} }
if (!historyToSplit && if (!historyToSplit &&
@ -302,29 +310,6 @@ class WalletsData extends React.Component {
stateObj = Object.assign(stateObj, { stateObj = Object.assign(stateObj, {
itemsList: 'loading', itemsList: 'loading',
}); });
} else if ( // dirty first txhistory load workaround
!historyToSplit &&
this.props.ActiveCoin.txhistory &&
this.props.ActiveCoin.txhistory !== 'loading' &&
this.props.ActiveCoin.txhistory !== 'no data' &&
this.props.ActiveCoin.txhistory.length
) {
historyToSplit = sortByDate(this.props.ActiveCoin.txhistory);
historyToSplit = historyToSplit.slice(
(this.state.activePage - 1) * this.state.itemsPerPage,
this.state.activePage * this.state.itemsPerPage
);
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,
});
}
} }
stateObj = Object.assign(stateObj, { stateObj = Object.assign(stateObj, {
@ -337,7 +322,7 @@ class WalletsData extends React.Component {
} }
updateCurrentPage(page) { updateCurrentPage(page) {
let historyToSplit = sortByDate(this.props.ActiveCoin.txhistory); let historyToSplit = sortByDate(this.props.ActiveCoin.txhistory, this.props.ActiveCoin.mode);
historyToSplit = historyToSplit.slice( historyToSplit = historyToSplit.slice(
(page - 1) * this.state.itemsPerPage, (page - 1) * this.state.itemsPerPage,
page * this.state.itemsPerPage page * this.state.itemsPerPage

4
react/src/components/dashboard/walletsData/walletsData.render.js

@ -46,7 +46,7 @@ export const PaginationRender = function(paginationFrom, paginationTo) {
const disableNextBtn = this.state.activePage >= Math.floor(this.props.ActiveCoin.txhistory.length / this.state.itemsPerPage); const disableNextBtn = this.state.activePage >= Math.floor(this.props.ActiveCoin.txhistory.length / this.state.itemsPerPage);
return ( return (
<div className="row unselectable"> <div className="row unselectable padding-top-20">
<div className="col-sm-5"> <div className="col-sm-5">
<div className="dataTables_info"> <div className="dataTables_info">
{ translate('INDEX.SHOWING') }&nbsp; { translate('INDEX.SHOWING') }&nbsp;
@ -117,7 +117,7 @@ export const AddressListRender = function() {
if (isMultiPublicAddress || if (isMultiPublicAddress ||
isMultiPrivateAddress) { isMultiPrivateAddress) {
return ( return (
<div className={ `btn-group bootstrap-select form-control form-material showkmdwalletaddrs show-tick ${(this.state.addressSelectorOpen ? 'open' : '')}` }> <div className={ `btn-group bootstrap-select form-control form-material showkmdwalletaddrs show-tick ${(this.state.addressSelectorOpen ? 'open margin-bottom-10' : 'margin-bottom-10')}` }>
<button <button
type="button" type="button"
className="btn dropdown-toggle btn-info" className="btn dropdown-toggle btn-info"

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

@ -73,6 +73,7 @@ class WalletsProgress extends React.Component {
} }
if (temp[i].indexOf('progress=') > -1) { if (temp[i].indexOf('progress=') > -1) {
currentProgress = Number(temp[i].replace('progress=', '')) * 1000; currentProgress = Number(temp[i].replace('progress=', '')) * 1000;
currentProgress = currentProgress >= 100 ? 100 : currentProgress;
} }
} }
@ -196,14 +197,14 @@ class WalletsProgress extends React.Component {
} }
} else if (this.props.Settings.debugLog.indexOf('Rescanning last') > -1) { } else if (this.props.Settings.debugLog.indexOf('Rescanning last') > -1) {
return ( return (
`: ({ translate('INDEX.RESCANNING_LAST_BLOCKS') })` `: (${ translate('INDEX.RESCANNING_LAST_BLOCKS') })`
); );
} else if ( } else if (
this.props.Settings.debugLog.indexOf('LoadExternalBlockFile:') > -1 || this.props.Settings.debugLog.indexOf('LoadExternalBlockFile:') > -1 ||
this.props.Settings.debugLog.indexOf('Reindexing block file') > -1 this.props.Settings.debugLog.indexOf('Reindexing block file') > -1
) { ) {
return ( return (
`: ({ translate('INDEX.REINDEX') })` `: (${ translate('INDEX.REINDEX') })`
); );
} else { } else {
return ( return (

2
react/src/components/dashboard/walletsProgress/walletsProgress.render.js

@ -71,7 +71,7 @@ export const ChainActivationNotificationRender = function() {
); );
}; };
export const WalletsProgressRender = function () { export const WalletsProgressRender = function() {
return ( return (
<div <div
id="edex-footer" id="edex-footer"

3
react/src/translate/en.js

@ -194,7 +194,8 @@ export const _lang = {
'- Your External Wallet/daemon is setup, but is not setup with config settings like<br>', '- Your External Wallet/daemon is setup, but is not setup with config settings like<br>',
'ACTIVATING_CHAIN': 'Activating best chain', 'ACTIVATING_CHAIN': 'Activating best chain',
'KMD_STARTED': 'Komodo daemon has been started and is processing.<br>' + 'KMD_STARTED': 'Komodo daemon has been started and is processing.<br>' +
'Please wait while the best chain is being activated.', 'Please wait while the best chain is being activated.<br>' +
'Tip: in case sync is stuck restart the wallet.',
'CONNECTIONS': 'Connections', 'CONNECTIONS': 'Connections',
'TRANSPARENT_BALANCE': 'Transparent Balance', 'TRANSPARENT_BALANCE': 'Transparent Balance',
'Z_BALANCE': 'Private (Z) Balance', 'Z_BALANCE': 'Private (Z) Balance',

13
react/src/util/sort.js

@ -1,10 +1,13 @@
export function sortByDate(data) { export function sortByDate(data, sortKey) {
return data.sort(function(a, b) { return data.sort(function(a, b) {
if (a.confirmations && if (a[sortKey] < b[sortKey]) {
b.confirmations) { return -1;
return a.confirmations - b.confirmations; }
} else {
if (a[sortKey] > b[sortKey]) {
return 1; return 1;
} }
return 0;
}); });
} }
Loading…
Cancel
Save