From 3b0292455348414c62a21c223bc5ee3a19ca82cb Mon Sep 17 00:00:00 2001 From: Petr Balashov Date: Mon, 29 May 2017 19:15:53 +0200 Subject: [PATCH 1/5] es6 string literals (wip) --- react/src/actions/addCoin.js | 16 +++---- react/src/components/toaster/toaster-item.js | 14 +++--- react/src/components/toaster/toaster.js | 49 ++++++++++++-------- 3 files changed, 44 insertions(+), 35 deletions(-) diff --git a/react/src/actions/addCoin.js b/react/src/actions/addCoin.js index dfa13a0..2b5f5c7 100644 --- a/react/src/actions/addCoin.js +++ b/react/src/actions/addCoin.js @@ -49,10 +49,10 @@ export function addCoin(coin, mode, syncOnly, port) { }; return dispatch => { - startIguanaInstance(modeToValue[mode] + '/sync', coin) + startIguanaInstance(`${modeToValue[mode]}/sync`, coin) .then(function(json) { setTimeout(function() { - console.log('started ' + coin + ' / ' + modeToValue[mode] + ' fork', json); + console.log(`started ${coin} / ${modeToValue[mode]} fork`, json); dispatch(iguanaAddCoin(coin, mode, _acData, json.result)); }, 2000); }); @@ -79,12 +79,12 @@ export function iguanaAddCoin(coin, mode, acData, port) { 'timestamp': _timestamp, 'function': 'iguanaAddCoin', 'type': 'post', - 'url': 'http://127.0.0.1:' + (port ? port : Config.iguanaCorePort), + 'url': `http://127.0.0.1:${(port ? port : Config.iguanaCorePort)}`, 'payload': acData, 'status': 'pending', })); - return fetch('http://127.0.0.1:' + (port ? port : Config.iguanaCorePort), { + return fetch(`http://127.0.0.1:${(port ? port : Config.iguanaCorePort)}`, { method: 'POST', body: JSON.stringify(acData), }) @@ -160,12 +160,12 @@ export function shepherdHerd(coin, mode, path) { if (checkCoinType(coin) === 'ac') { acData = startAssetChain(path.result, coin, mode); const supply = startAssetChain(path.result, coin, mode, true); - herdData.ac_options.push('-ac_supply=' + supply); + herdData.ac_options.push(`-ac_supply=${supply}`); } console.log('herdData', herdData); return dispatch => { - return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/herd', { + return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/herd`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -192,7 +192,7 @@ export function addCoinResult(coin, mode) { }; return dispatch => { - dispatch(triggerToaster(true, coin + ' ' + translate('TOASTR.STARTED_IN') + ' ' + modeToValue[mode] + ' ' + translate('TOASTR.MODE'), translate('TOASTR.COIN_NOTIFICATION'), 'success')); + dispatch(triggerToaster(true, `${coin} ${translate('TOASTR.STARTED_IN')} ${modeToValue[mode]} ${translate('TOASTR.MODE')}`, translate('TOASTR.COIN_NOTIFICATION'), 'success')); dispatch(toggleAddcoinModal(false, false)); dispatch(getDexCoins()); } @@ -200,7 +200,7 @@ export function addCoinResult(coin, mode) { export function _shepherdGetConfig(coin, mode) { return dispatch => { - return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/getconf', { + return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/getconf`, { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/react/src/components/toaster/toaster-item.js b/react/src/components/toaster/toaster-item.js index 94904d7..b422710 100644 --- a/react/src/components/toaster/toaster-item.js +++ b/react/src/components/toaster/toaster-item.js @@ -1,6 +1,6 @@ -import React from "react"; -import {dismissToasterMessage} from "../../actions/actionCreators"; -import Store from "../../store"; +import React from 'react'; +import { dismissToasterMessage } from '../../actions/actionCreators'; +import Store from '../../store'; // each toast will be displayed for 5 seconds const DISPLAY_LENGTH_MILLIS = 5000; @@ -10,7 +10,6 @@ const DISPLAY_LENGTH_MILLIS = 5000; * each messages has a type, title and a content message */ class ToasterItem extends React.Component { - constructor(props) { super(props); this.state = { @@ -60,9 +59,10 @@ class ToasterItem extends React.Component { } return ( -
-
{ this.state.title }
{ this.state.message }
diff --git a/react/src/components/toaster/toaster.js b/react/src/components/toaster/toaster.js index d8fdf6d..5fa72fa 100644 --- a/react/src/components/toaster/toaster.js +++ b/react/src/components/toaster/toaster.js @@ -1,7 +1,7 @@ -import React from "react"; -import {dismissToasterMessage} from "../../actions/actionCreators"; -import Store from "../../store"; -import ToasterItem from "./toaster-item"; +import React from 'react'; +import { dismissToasterMessage } from '../../actions/actionCreators'; +import Store from '../../store'; +import ToasterItem from './toaster-item'; /** * Container component used for creating multiple toasts @@ -17,7 +17,7 @@ class Toaster extends React.Component { componentWillReceiveProps(props) { if (props && - props.toasts) { + props.toasts) { this.setState({ toasts: props.toasts, toastId: props.toasts.length @@ -34,24 +34,33 @@ class Toaster extends React.Component { Store.dispatch(dismissToasterMessage(toastId)); } + renderToasts() { + if (this.state.toasts && + this.state.toasts.length) { + this.state.toasts.map((toast) => { + // sets the toastId for all new toasts + if (!toast.toastId) { + toast.toastId = this.toastId++; + } + + return ( + + ); + }); + } else { + return null; + } + } + // render all current toasts render() { return ( -
diff --git a/react/src/components/dashboard/walletsData.js b/react/src/components/dashboard/walletsData.js index 592960c..1b551ad 100644 --- a/react/src/components/dashboard/walletsData.js +++ b/react/src/components/dashboard/walletsData.js @@ -82,6 +82,7 @@ class WalletsData extends React.Component { } } + // deprecated toggleCacheApi() { const _useCache = !this.state.useCache; @@ -463,6 +464,7 @@ class WalletsData extends React.Component { } }*/ + // deprecated renderUseCacheToggle() { if (this.props.ActiveCoin.mode === 'basilisk') { return ( @@ -548,11 +550,11 @@ class WalletsData extends React.Component { this.props.Dashboard.activeHandle[this.props.ActiveCoin.coin] && this.props.ActiveCoin.mode === 'basilisk') { return ( -
+
-
+
+ style={{ backgroundImage: `url("assets/images/bg/${this.props.activeSection}_transparent_header_bg.png")`, backgroundRepeat: 'no-repeat', backgroundPosition: '0%' }}>

EasyDEX

  1. { translate('INDEX.DASHBOARD') }
  2. diff --git a/react/src/components/dashboard/walletsNative.js b/react/src/components/dashboard/walletsNative.js index 9951832..1e2d5ef 100644 --- a/react/src/components/dashboard/walletsNative.js +++ b/react/src/components/dashboard/walletsNative.js @@ -29,10 +29,10 @@ class WalletsNative extends React.Component { return (
    -
    +
    1. - { this.props.ActiveCoin.coin } + { this.props.ActiveCoin.coin }
    diff --git a/react/src/components/dashboard/walletsNativeSend.js b/react/src/components/dashboard/walletsNativeSend.js index 69884ef..52e3e00 100644 --- a/react/src/components/dashboard/walletsNativeSend.js +++ b/react/src/components/dashboard/walletsNativeSend.js @@ -80,7 +80,7 @@ class WalletsNativeSend extends React.Component { renderAddressList() { return ( -
    +
    - + +
    ); diff --git a/react/src/components/main/main.js b/react/src/components/main/main.js index 9eebbd9..461ae17 100644 --- a/react/src/components/main/main.js +++ b/react/src/components/main/main.js @@ -8,6 +8,8 @@ import { iguanaActiveHandle } from '../../actions/actionCreators'; +const IGUANA_ACTIVE_HANDLE_TIMEOUT = 30000; + class Main extends React.Component { constructor(props) { super(props); @@ -24,7 +26,7 @@ class Main extends React.Component { Store.dispatch(iguanaActiveHandle()); const _iguanaActiveHandle = setInterval(function() { Store.dispatch(iguanaActiveHandle()); - }, 30000); + }, IGUANA_ACTIVE_HANDLE_TIMEOUT); this.setState(Object.assign({}, this.state, { activeHandleInterval: _iguanaActiveHandle, From 9e0b2c3e0d6f462055eaa5da5139c6a62d2df8c5 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Wed, 31 May 2017 20:58:56 +0300 Subject: [PATCH 4/5] merge fix --- react/src/styles/index.scss | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/react/src/styles/index.scss b/react/src/styles/index.scss index 7eceb0c..ff355cf 100644 --- a/react/src/styles/index.scss +++ b/react/src/styles/index.scss @@ -501,17 +501,4 @@ input:checked + .slider:before { #app { height: 100%; -} - -/*.toaster .single-toast:nth-child(0) { - bottom: 12px; -} -.toaster .single-toast:nth-child(1) { - bottom: 102px; -} -.toaster .single-toast:nth-child(2) { - bottom: 192px; -} -.toaster .single-toast:nth-child(3) { - bottom: 282px; -}*/ \ No newline at end of file +} \ No newline at end of file From 8563d273d25a2f1e4dea6701194150d066c7074a Mon Sep 17 00:00:00 2001 From: pbca26 Date: Wed, 31 May 2017 21:33:50 +0300 Subject: [PATCH 5/5] remaining es6 fat arrows --- react/src/components/addcoin/addcoin.js | 8 +++---- .../src/components/dashboard/coinTileItem.js | 24 ++++++++++++------- react/src/components/login/login.js | 7 ++++-- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/react/src/components/addcoin/addcoin.js b/react/src/components/addcoin/addcoin.js index be16812..4309a62 100644 --- a/react/src/components/addcoin/addcoin.js +++ b/react/src/components/addcoin/addcoin.js @@ -97,12 +97,12 @@ class AddCoin extends React.Component { modalClassName: props.display ? 'show fade' : 'show fade', })); - setTimeout(function() { + setTimeout(() => { this.setState(Object.assign({}, this.state, { display: props.display, modalClassName: props.display ? 'show in' : 'hide', })); - }.bind(this), 100); + }, 100); } } @@ -216,7 +216,7 @@ class AddCoin extends React.Component { for (let i = 1; i < this.state.coins.length; i++) { const _item = this.state.coins[i]; - setTimeout(function() { + setTimeout(() => { Store.dispatch(addCoin( _item.selectedCoin.split('|')[0], _item.mode, @@ -233,7 +233,7 @@ class AddCoin extends React.Component { Store.dispatch(toggleAddcoinModal(false, false)); } - }.bind(this), 2000 * i); + }, 2000 * i); } } diff --git a/react/src/components/dashboard/coinTileItem.js b/react/src/components/dashboard/coinTileItem.js index 23607a7..5b5a40e 100644 --- a/react/src/components/dashboard/coinTileItem.js +++ b/react/src/components/dashboard/coinTileItem.js @@ -22,6 +22,9 @@ import { import Store from '../../store'; const BASILISK_CACHE_UPDATE_TIMEOUT = 240000; +const IGUNA_ACTIVE_HANDLE_TIMEOUT = 3000; +const IGUNA_ACTIVE_HANDLE_TIMEOUT_KMD_NATIVE = 15000; +const NATIVE_MIN_SYNC_PERCENTAGE_THRESHOLD = 90; class CoinTileItem extends React.Component { constructor(props) { @@ -41,10 +44,13 @@ class CoinTileItem extends React.Component { dispatchCoinActions(coin, mode) { if (mode === 'native') { Store.dispatch(iguanaActiveHandle(true)); + const syncPercentage = this.props.Dashboard && this.props.Dashboard.progress && (parseFloat(parseInt(this.props.Dashboard.progress.blocks, 10) * 100 / parseInt(this.props.Dashboard.progress.longestchain, 10)).toFixed(2)).replace('NaN', 0); + if (this.props.Dashboard.progress && this.props.Dashboard.progress.blocks && this.props.Dashboard.progress.longestchain && - this.props.Dashboard.progress.blocks === this.props.Dashboard.progress.longestchain) { + syncPercentage && + syncPercentage >= NATIVE_MIN_SYNC_PERCENTAGE_THRESHOLD) { Store.dispatch(getSyncInfoNative(coin, true)); Store.dispatch(getKMDBalanceTotal(coin)); Store.dispatch(getNativeTxHistory(coin)); @@ -63,6 +69,7 @@ class CoinTileItem extends React.Component { } if (mode === 'basilisk') { const useAddress = this.props.ActiveCoin.mainBasiliskAddress ? this.props.ActiveCoin.mainBasiliskAddress : this.props.Dashboard.activeHandle[coin]; + Store.dispatch(iguanaActiveHandle(true)); Store.dispatch(getKMDAddressesNative(coin, mode, useAddress)); Store.dispatch(getShepherdCache(JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey, coin)); @@ -74,8 +81,8 @@ class CoinTileItem extends React.Component { if (!this.props.ActiveCoin.addresses) { Store.dispatch(getAddressesByAccount(coin, mode)); } + Store.dispatch(getBasiliskTransactionsList(coin, useAddress)); - //Store.dispatch(iguanaEdexBalance(coin, mode)); } } } @@ -89,15 +96,15 @@ class CoinTileItem extends React.Component { this.dispatchCoinActions(coin, mode); if (mode === 'full') { - const _iguanaActiveHandle = setInterval(function() { + const _iguanaActiveHandle = setInterval(() => { this.dispatchCoinActions(coin, mode); - }.bind(this), 3000); + }, IGUNA_ACTIVE_HANDLE_TIMEOUT); Store.dispatch(startInterval('sync', _iguanaActiveHandle)); } if (mode === 'native') { - const _iguanaActiveHandle = setInterval(function() { + const _iguanaActiveHandle = setInterval(() => { this.dispatchCoinActions(coin, mode); - }.bind(this), coin === 'KMD' ? 15000 : 3000); + }, coin === 'KMD' ? IGUNA_ACTIVE_HANDLE_TIMEOUT_KMD_NATIVE : IGUNA_ACTIVE_HANDLE_TIMEOUT); Store.dispatch(startInterval('sync', _iguanaActiveHandle)); } if (mode === 'basilisk') { @@ -113,9 +120,9 @@ class CoinTileItem extends React.Component { 'address': _basiliskMainAddress, })); - const _iguanaActiveHandle = setInterval(function() { + const _iguanaActiveHandle = setInterval(() => { this.dispatchCoinActions(coin, mode); - }.bind(this), 3000); + }, IGUNA_ACTIVE_HANDLE_TIMEOUT); const _basiliskCache = setInterval(() => { Store.dispatch(fetchNewCacheData({ @@ -128,7 +135,6 @@ class CoinTileItem extends React.Component { }, BASILISK_CACHE_UPDATE_TIMEOUT); Store.dispatch(startInterval('sync', _iguanaActiveHandle)); Store.dispatch(startInterval('basilisk', _basiliskCache)); - // basilisk } } } diff --git a/react/src/components/login/login.js b/react/src/components/login/login.js index 4e70ca3..30f8593 100644 --- a/react/src/components/login/login.js +++ b/react/src/components/login/login.js @@ -14,6 +14,9 @@ import { import Store from '../../store'; import { PassPhraseGenerator } from '../../util/crypto/passphrasegenerator'; +const IGUNA_ACTIVE_HANDLE_TIMEOUT = 3000; +const IGUNA_ACTIVE_COINS_TIMEOUT = 10000; + class Login extends React.Component { constructor(props) { super(props); @@ -43,7 +46,7 @@ class Login extends React.Component { const _iguanaActiveHandle = setInterval(() => { Store.dispatch(getSyncOnlyForks()); - }, 3000); + }, IGUNA_ACTIVE_HANDLE_TIMEOUT); Store.dispatch(startInterval('syncOnly', _iguanaActiveHandle)); Store.dispatch(toggleSyncOnlyModal(true)); @@ -85,7 +88,7 @@ class Login extends React.Component { if (!this.props.Interval.interval.activeCoins) { const _iguanaActiveCoins = setInterval(() => { Store.dispatch(getDexCoins()); - }, 10000); + }, IGUNA_ACTIVE_COINS_TIMEOUT); Store.dispatch(startInterval('activeCoins', _iguanaActiveCoins)); }