Browse Source

walletsData add/remove sockets

all-modes
pbca26 8 years ago
parent
commit
ced18c4b33
  1. 3
      react/src/actions/actionCreators.js
  2. 2
      react/src/actions/actions/addressBalance.js
  3. 8
      react/src/components/dashboard/qrModal/qrModal.js
  4. 11
      react/src/components/dashboard/receiveCoin/receiveCoin.render.js
  5. 2
      react/src/components/dashboard/settings/settings.render.js
  6. 19
      react/src/components/dashboard/walletsData/walletsData.js
  7. 8
      react/src/translate/translate.js

3
react/src/actions/actionCreators.js

@ -322,7 +322,6 @@ export function setBasiliskMainAddress(json, coin, mode) {
} }
export function getNativeTxHistoryState(json) { export function getNativeTxHistoryState(json) {
console.log('getNativeTxHistoryState', json.result.length);
if (json && if (json &&
json.error) { json.error) {
json = null; json = null;
@ -332,8 +331,6 @@ export function getNativeTxHistoryState(json) {
json = 'no data'; json = 'no data';
} }
console.log('getNativeTxHistoryState', json);
return { return {
type: DASHBOARD_ACTIVE_COIN_NATIVE_TXHISTORY, type: DASHBOARD_ACTIVE_COIN_NATIVE_TXHISTORY,
txhistory: json, txhistory: json,

2
react/src/actions/actions/addressBalance.js

@ -249,6 +249,7 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
for (let a = 0; a < result.length; a++) { for (let a = 0; a < result.length; a++) {
newAddressArray[a] = []; newAddressArray[a] = [];
if (result[a]) {
for (let b = 0; b < result[a].length; b++) { for (let b = 0; b < result[a].length; b++) {
let filteredArray; let filteredArray;
@ -270,6 +271,7 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
}; };
} }
} }
}
// get zaddr balance // get zaddr balance
if (result[1] && if (result[1] &&

8
react/src/components/dashboard/qrModal/qrModal.js

@ -19,14 +19,14 @@ class QRModal extends React.Component {
this.closeModal = this.closeModal.bind(this); this.closeModal = this.closeModal.bind(this);
this.handleScan = this.handleScan.bind(this); this.handleScan = this.handleScan.bind(this);
this.handleError = this.handleError.bind(this); this.handleError = this.handleError.bind(this);
document.body.addEventListener('click', this.closeModal);
} }
handleScan(data) { handleScan(data) {
if (data !== null) { if (data !== null) {
if (this.props.mode === 'scan') { if (this.props.mode === 'scan') {
this.props.setRecieverFromScan(data) this.props.setRecieverFromScan(data);
} }
this.closeModal(); this.closeModal();
} }
} }
@ -60,10 +60,6 @@ class QRModal extends React.Component {
this.setState({ this.setState({
modalIsOpen: false, modalIsOpen: false,
}); });
if (this.props.mode === 'scan') {
ReactDOM.unmountComponentAtNode(document.getElementById('webcam'));
}
} }
render() { render() {

11
react/src/components/dashboard/receiveCoin/receiveCoin.render.js

@ -26,9 +26,7 @@ export const AddressActionsBasiliskModeRender = function(address) {
onClick={ () => this._validateAddressBasilisk(address) }> onClick={ () => this._validateAddressBasilisk(address) }>
<i className="icon fa-info-circle"></i> <i className="icon fa-info-circle"></i>
</span> </span>
<QRModal <QRModal content={ address } />
content={address}
/>
</td> </td>
); );
}; };
@ -45,9 +43,7 @@ export const AddressActionsNonBasiliskModeRender = function(address, type) {
onClick={ () => this._copyCoinAddress(address) }> onClick={ () => this._copyCoinAddress(address) }>
<i className="icon wb-copy"></i> { translate('INDEX.COPY') } <i className="icon wb-copy"></i> { translate('INDEX.COPY') }
</button> </button>
<QRModal <QRModal content={ address } />
content={address}
/>
</td> </td>
); );
}; };
@ -76,7 +72,8 @@ export const ReceiveCoinRender = function() {
<header className="panel-heading"> <header className="panel-heading">
{this.isNativeMode() && {this.isNativeMode() &&
<div className="panel-actions"> <div className="panel-actions">
<div className={ 'dropdown' + (this.state.openDropMenu ? ' open' : '') } <div
className={ 'dropdown' + (this.state.openDropMenu ? ' open' : '') }
onClick={ this.openDropMenu }> onClick={ this.openDropMenu }>
<a className="dropdown-toggle white btn btn-warning"> <a className="dropdown-toggle white btn btn-warning">
<i className="icon md-arrows margin-right-10"></i> { translate('INDEX.GET_NEW_ADDRESS') } <i className="icon md-arrows margin-right-10"></i> { translate('INDEX.GET_NEW_ADDRESS') }

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

@ -593,7 +593,7 @@ export const SettingsRender = function() {
<textarea <textarea
type="text" type="text"
className="form-control" className="form-control"
name="cliCmd" name="cliCmdString"
id="cliCmd" id="cliCmd"
value={ this.state.cliCmdString } value={ this.state.cliCmdString }
onChange={ this.updateInput }></textarea> onChange={ this.updateInput }></textarea>

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

@ -64,7 +64,6 @@ class WalletsData extends React.Component {
this.basiliskRefreshActionOne = this.basiliskRefreshActionOne.bind(this); this.basiliskRefreshActionOne = this.basiliskRefreshActionOne.bind(this);
this.handleClickOutside = this.handleClickOutside.bind(this); this.handleClickOutside = this.handleClickOutside.bind(this);
this.refreshTxHistory = this.refreshTxHistory.bind(this); this.refreshTxHistory = this.refreshTxHistory.bind(this);
socket.on('messages', msg => this.updateSocketsData(msg));
} }
componentWillMount() { componentWillMount() {
@ -73,6 +72,14 @@ class WalletsData extends React.Component {
this.handleClickOutside, this.handleClickOutside,
false false
); );
setTimeout(() => {
if (this.props.ActiveCoin.mode === 'basilisk') {
socket.on('messages', msg => this.updateSocketsData(msg));
} else {
socket.removeAllListeners('messages');
}
}, 100);
} }
componentWillUnmount() { componentWillUnmount() {
@ -81,6 +88,8 @@ class WalletsData extends React.Component {
this.handleClickOutside, this.handleClickOutside,
false false
); );
socket.removeAllListeners('messages');
} }
handleClickOutside(e) { handleClickOutside(e) {
@ -576,8 +585,14 @@ class WalletsData extends React.Component {
if (this.props && if (this.props &&
this.props.ActiveCoin && this.props.ActiveCoin &&
this.props.ActiveCoin.coin && this.props.ActiveCoin.coin &&
(
this.props.ActiveCoin.mode !== 'native' &&
!this.props.ActiveCoin.send && !this.props.ActiveCoin.send &&
!this.props.ActiveCoin.receive) { !this.props.ActiveCoin.receive
) || (
this.props.ActiveCoin.mode === 'native' &&
this.props.ActiveCoin.nativeActiveSection === 'default'
)) {
return WalletsDataRender.call(this); return WalletsDataRender.call(this);
} else { } else {
return null; return null;

8
react/src/translate/translate.js

@ -13,13 +13,13 @@ export function translate(langID) {
_lang[defaultLang][langIDComponents[0]][langIDComponents[1]]) { _lang[defaultLang][langIDComponents[0]][langIDComponents[1]]) {
return _lang[defaultLang][langIDComponents[0]][langIDComponents[1]]; return _lang[defaultLang][langIDComponents[0]][langIDComponents[1]];
} else { } else {
console.warn('Missing translation in js/' + defaultLang.toLowerCase() + '.js ' + langID); console.warn(`Missing translation ${langID} in js/${defaultLang.toLowerCase()}.js`);
return '--> ' + langID + ' <--'; return `--> ${langID} <--`;
} }
} else { } else {
if (langID.length) { if (langID.length) {
console.warn('Missing translation in js/' + defaultLang.toLowerCase() + '.js ' + langID); console.warn(`Missing translation ${langID} in js/${defaultLang.toLowerCase()}.js`);
return '--> ' + langID + ' <--'; return `--> ${langID} <--`;
} }
} }
} }
Loading…
Cancel
Save