Browse Source

sorting fix

all-modes
pbca26 7 years ago
parent
commit
d6bba8eb10
  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. 4
      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) {
if (coin !== this.props.ActiveCoin.coin) {
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(
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 }
</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>
{ 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,
useCache: true,
coin: null,
txhistory: null,
};
this.updateInput = this.updateInput.bind(this);
this.toggleBasiliskActionsMenu = this.toggleBasiliskActionsMenu.bind(this);
@ -152,7 +153,9 @@ class WalletsData extends React.Component {
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) {
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);
this.setState({
@ -252,6 +255,16 @@ class WalletsData extends React.Component {
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) {
let historyToSplit;
let stateObj = {};
@ -270,26 +283,21 @@ class WalletsData extends React.Component {
this.props.ActiveCoin.txhistory !== 'loading' &&
this.props.ActiveCoin.txhistory !== 'no data' &&
this.props.ActiveCoin.txhistory.length) {
if (!this.state.itemsList ||
(this.state.itemsList && !this.state.itemsList.length) ||
(props.ActiveCoin.txhistory !== this.props.ActiveCoin.txhistory)) {
historyToSplit = sortByDate(this.props.ActiveCoin.txhistory);
historyToSplit = sortByDate(this.indexTxHistory(this.props.ActiveCoin.txhistory), this.props.ActiveCoin.mode === 'basilisk' ? 'index' : 'confirmations');
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)) {
if (!this.state.itemsList || (this.state.coin && this.state.coin !== this.props.ActiveCoin.coin) || (
JSON.stringify(this.props.ActiveCoin.txhistory) !== JSON.stringify(this.state.txhistory))) {
stateObj = Object.assign(stateObj, {
itemsList: historyToSplit,
txhistory: this.props.ActiveCoin.txhistory,
});
}
}
}
if (!historyToSplit &&
@ -302,29 +310,6 @@ class WalletsData extends React.Component {
stateObj = Object.assign(stateObj, {
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, {
@ -337,7 +322,7 @@ class WalletsData extends React.Component {
}
updateCurrentPage(page) {
let historyToSplit = sortByDate(this.props.ActiveCoin.txhistory);
let historyToSplit = sortByDate(this.props.ActiveCoin.txhistory, this.props.ActiveCoin.mode);
historyToSplit = historyToSplit.slice(
(page - 1) * 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);
return (
<div className="row unselectable">
<div className="row unselectable padding-top-20">
<div className="col-sm-5">
<div className="dataTables_info">
{ translate('INDEX.SHOWING') }&nbsp;
@ -117,7 +117,7 @@ export const AddressListRender = function() {
if (isMultiPublicAddress ||
isMultiPrivateAddress) {
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
type="button"
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) {
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) {
return (
`: ({ translate('INDEX.RESCANNING_LAST_BLOCKS') })`
`: (${ translate('INDEX.RESCANNING_LAST_BLOCKS') })`
);
} else if (
this.props.Settings.debugLog.indexOf('LoadExternalBlockFile:') > -1 ||
this.props.Settings.debugLog.indexOf('Reindexing block file') > -1
) {
return (
`: ({ translate('INDEX.REINDEX') })`
`: (${ translate('INDEX.REINDEX') })`
);
} else {
return (

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

@ -39,7 +39,7 @@ export const LoadingBlocksRender = function() {
export const TranslationComponentsRender = function(translationID) {
const translationComponents = translate(translationID).split('<br>');
return translationComponents.map((translation, idx) =>
<span key={idx}>
{ translation }
@ -71,7 +71,7 @@ export const ChainActivationNotificationRender = function() {
);
};
export const WalletsProgressRender = function () {
export const WalletsProgressRender = function() {
return (
<div
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>',
'ACTIVATING_CHAIN': 'Activating best chain',
'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',
'TRANSPARENT_BALANCE': 'Transparent 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) {
if (a.confirmations &&
b.confirmations) {
return a.confirmations - b.confirmations;
} else {
if (a[sortKey] < b[sortKey]) {
return -1;
}
if (a[sortKey] > b[sortKey]) {
return 1;
}
return 0;
});
}
Loading…
Cancel
Save