Browse Source

txinfo modal bugfix

all-modes
pbca26 8 years ago
parent
commit
dbd327a4d8
  1. 48
      react/src/components/dashboard/walletsData/walletsData.js
  2. 2
      react/src/components/dashboard/walletsData/walletsData.render.js
  3. 3
      react/src/components/dashboard/walletsTxInfo/walletsTxInfo.js
  4. 9
      react/src/util/sort.js

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

@ -32,7 +32,7 @@ import {
import { SocketProvider } from 'socket.io-react';
import io from 'socket.io-client';
const socket = io.connect('http://127.0.0.1:' + Config.agamaPort);
const socket = io.connect(`http://127.0.0.1:${Config.agamaPort}`);
class WalletsData extends React.Component {
constructor(props) {
@ -401,22 +401,30 @@ class WalletsData extends React.Component {
}
renderAddressByType(type) {
if (this.props.ActiveCoin.addresses &&
this.props.ActiveCoin.addresses[type] &&
this.props.ActiveCoin.addresses[type].length) {
const _addresses = this.props.ActiveCoin.addresses;
if (_addresses &&
_addresses[type] &&
_addresses[type].length) {
let items = [];
const _cache = this.props.ActiveCoin.cache;
const _coin = this.props.ActiveCoin.coin;
for (let i = 0; i < this.props.ActiveCoin.addresses[type].length; i++) {
const address = this.props.ActiveCoin.addresses[type][i];
for (let i = 0; i < _addresses[type].length; i++) {
const address = _addresses[type][i].address;
let _amount = address.amount;
if (this.props.ActiveCoin.mode === 'basilisk') {
_amount = this.props.ActiveCoin.cache && this.props.ActiveCoin.cache[this.props.ActiveCoin.coin] && this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][address.address] && this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][address.address].getbalance.data && this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][address.address].getbalance.data.balance ? this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][address.address].getbalance.data.balance : 'N/A';
_amount = _cache && _cache[_coin] && _cache[_coin][address] && _cache[_coin][address].getbalance.data && _cache[_coin][address].getbalance.data.balance ? _cache[_coin][address].getbalance.data.balance : 'N/A';
}
items.push(
<li key={address.address}>
<a onClick={ () => this.updateAddressSelection(address.address, type, _amount) }><i className={ type === 'public' ? 'icon fa-eye' : 'icon fa-eye-slash' }></i> <span className="text">[ { _amount } { this.props.ActiveCoin.coin } ] { address.address }</span><span className="glyphicon glyphicon-ok check-mark"></span></a>
<li key={address}>
<a onClick={ () => this.updateAddressSelection(address, type, _amount) }>
<i className={ type === 'public' ? 'icon fa-eye' : 'icon fa-eye-slash' }></i>&nbsp;&nbsp;
<span className="text">[ { _amount } { _coin } ]{ address }</span>
<span className="glyphicon glyphicon-ok check-mark"></span>
</a>
</li>
);
}
@ -435,14 +443,19 @@ class WalletsData extends React.Component {
renderAddressAmount() {
if (this.hasPublicAdresses()) {
for (let i = 0; i < this.props.ActiveCoin.addresses.public.length; i++) {
if (this.props.ActiveCoin.addresses.public[i].address === this.state.currentAddress) {
if (this.props.ActiveCoin.addresses.public[i].amount &&
this.props.ActiveCoin.addresses.public[i].amount !== 'N/A') {
return this.props.ActiveCoin.addresses.public[i].amount;
const _addresses = this.props.ActiveCoin.addresses;
const _cache = this.props.ActiveCoin.cache;
const _coin = this.props.ActiveCoin.coin;
for (let i = 0; i < _addresses.public.length; i++) {
if (_addresses.public[i].address === this.state.currentAddress) {
if (_addresses.public[i].amount &&
_addresses.public[i].amount !== 'N/A') {
return _addresses.public[i].amount;
} else {
const address = this.props.ActiveCoin.addresses.public[i].address;
const _amount = this.props.ActiveCoin.cache[this.props.ActiveCoin.coin] && this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][address] && this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][address].getbalance.data && this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][address].getbalance.data.balance ? this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][address].getbalance.data.balance : 'N/A';
const address = _addresses.public[i].address;
const _amount = _cache[_coin] && _cache[_coin][address] && _cache[_coin][address].getbalance.data && _cache[_coin][address].getbalance.data.balance ? _cache[_coin][address].getbalance.data.balance : 'N/A';
return _amount;
}
}
@ -456,7 +469,8 @@ class WalletsData extends React.Component {
if (this.state.currentAddress) {
return (
<span>
<i className={ this.state.addressType === 'public' ? 'icon fa-eye' : 'icon fa-eye-slash' }></i> <span className="text">[ { this.renderAddressAmount() } { this.props.ActiveCoin.coin } ] { this.state.currentAddress }</span>
<i className={ 'icon fa-eye' + (this.state.addressType === 'public' ? '' : '-slash') }></i>&nbsp;&nbsp;
<span className="text">[ { this.renderAddressAmount() } { this.props.ActiveCoin.coin } ]{ this.state.currentAddress }</span>
</span>
);
} else {

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

@ -83,7 +83,7 @@ export const TxHistoryListRender = function(tx, index) {
<button
type="button"
className="btn btn-xs white btn-info waves-effect waves-light btn-kmdtxid"
onClick={ () => this.toggleTxInfoModal(!this.props.ActiveCoin.showTransactionInfo, index) }>
onClick={ () => this.toggleTxInfoModal(!this.props.ActiveCoin.showTransactionInfo, ((this.state.activePage - 1) * this.state.itemsPerPage) + index) }>
<i className="icon fa-search"></i>
</button>
</td>

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

@ -1,4 +1,5 @@
import React from 'react';
import { sortByDate } from '../../../util/sort';
import { toggleDashboardTxInfoModal } from '../../../actions/actionCreators';
import Store from '../../../store';
import WalletsTxInfoRender from './walletsTxInfo.render';
@ -39,7 +40,7 @@ class WalletsTxInfo extends React.Component {
// into the rest of the components
(!this.isNativeMode() ||
(this.isNativeMode() && this.props.ActiveCoin.nativeActiveSection === 'default'))) {
const txInfo = this.props.ActiveCoin.txhistory[this.props.ActiveCoin.showTransactionInfoTxIndex];
const txInfo = sortByDate(this.props.ActiveCoin.txhistory)[this.props.ActiveCoin.showTransactionInfoTxIndex];
return WalletsTxInfoRender.call(this, txInfo);
}

9
react/src/util/sort.js

@ -1,5 +1,10 @@
export function sortByDate(data) {
return data.sort(function(a, b){
return new Date(b.blocktime || b.timestamp) - new Date(a.blocktime || a.timestamp);
return data.sort(function(a, b) {
if (a.timestamp &&
b.timestamp) {
return b.timestamp - a.timestamp;
} else {
return b.blocktime - a.blocktime;
}
});
}
Loading…
Cancel
Save