diff --git a/app/api/index.js b/app/api/index.js index 3873274d..272f1557 100644 --- a/app/api/index.js +++ b/app/api/index.js @@ -12,7 +12,5 @@ export function requestTicker(id) { export function requestTickers(ids) { return axios.all(ids.map(id => requestTicker(id))) - .then(axios.spread((btcTicker, ltcTicker) => { - return { btcTicker: btcTicker[0], ltcTicker: ltcTicker[0] } - })) -} \ No newline at end of file + .then(axios.spread((btcTicker, ltcTicker) => ({ btcTicker: btcTicker[0], ltcTicker: ltcTicker[0] }))) +} diff --git a/app/lnd/methods/index.js b/app/lnd/methods/index.js index 6782a3d1..7f8c12c9 100644 --- a/app/lnd/methods/index.js +++ b/app/lnd/methods/index.js @@ -20,7 +20,10 @@ export default function (lnd, event, msg, data) { switch (msg) { case 'info': info(lnd) - .then(infoData => event.sender.send('receiveInfo', infoData)) + .then((infoData) => { + event.sender.send('receiveInfo', infoData) + event.sender.send('receiveCryptocurrency', infoData.chains[0]) + }) .catch(error => console.log('info error: ', error)) break case 'newaddress': diff --git a/app/reducers/ipc.js b/app/reducers/ipc.js index a0823a20..7fadc84e 100644 --- a/app/reducers/ipc.js +++ b/app/reducers/ipc.js @@ -1,6 +1,7 @@ import createIpc from 'redux-electron-ipc' import { receiveInfo } from './info' import { receiveAddress } from './address' +import { receiveCryptocurrency } from './ticker' import { receivePeers, connectSuccess, disconnectSuccess } from './peers' import { receiveChannels, @@ -32,7 +33,8 @@ const ipc = createIpc({ pushchannelstatus, connectSuccess, disconnectSuccess, - receiveAddress + receiveAddress, + receiveCryptocurrency }) export default ipc diff --git a/app/reducers/ticker.js b/app/reducers/ticker.js index e426508e..c796a99f 100644 --- a/app/reducers/ticker.js +++ b/app/reducers/ticker.js @@ -45,7 +45,7 @@ export function recieveTickers({ btcTicker, ltcTicker }) { } } -export const fetchTicker = (id) => async (dispatch) => { +export const fetchTicker = () => async (dispatch) => { dispatch(getTickers()) const tickers = await requestTickers(['bitcoin', 'litecoin']) dispatch(recieveTickers(tickers)) @@ -54,8 +54,7 @@ export const fetchTicker = (id) => async (dispatch) => { } // Receive IPC event for receiveCryptocurrency -export const receiveCryptocurrency = (event, currency) => dispatch => { - console.log('currency: ', currency) +export const receiveCryptocurrency = (event, currency) => (dispatch) => { dispatch({ type: SET_CURRENCY, currency: cryptoTickers[currency] }) dispatch({ type: SET_CRYPTO, crypto: cryptoTickers[currency] }) } @@ -83,7 +82,7 @@ tickerSelectors.currentTicker = createSelector( cryptoSelector, bitcoinTickerSelector, litecoinTickerSelector, - (crypto, btcTicker, ltcTicker) => crypto === 'btc' ? btcTicker : ltcTicker + (crypto, btcTicker, ltcTicker) => (crypto === 'btc' ? btcTicker : ltcTicker) ) export { tickerSelectors } @@ -93,8 +92,8 @@ export { tickerSelectors } // ------------------------------------ const initialState = { tickerLoading: false, - currency: 'btc', - crypto: 'btc', + currency: '', + crypto: '', btcTicker: null, ltcTicker: null } @@ -103,4 +102,4 @@ export default function tickerReducer(state = initialState, action) { const handler = ACTION_HANDLERS[action.type] return handler ? handler(state, action) : state -} \ No newline at end of file +} diff --git a/app/routes/activity/components/Activity.js b/app/routes/activity/components/Activity.js index f22ad27a..85692c8e 100644 --- a/app/routes/activity/components/Activity.js +++ b/app/routes/activity/components/Activity.js @@ -106,7 +106,8 @@ Activity.propTypes = { setPayment: PropTypes.func.isRequired, setInvoice: PropTypes.func.isRequired, paymentModalOpen: PropTypes.bool.isRequired, - invoiceModalOpen: PropTypes.bool.isRequired + invoiceModalOpen: PropTypes.bool.isRequired, + currentTicker: PropTypes.object.isRequired } export default Activity diff --git a/app/routes/activity/components/components/Invoices.js b/app/routes/activity/components/components/Invoices.js index 443f3440..b95d657d 100644 --- a/app/routes/activity/components/components/Invoices.js +++ b/app/routes/activity/components/components/Invoices.js @@ -108,7 +108,8 @@ Invoices.propTypes = { invoices: PropTypes.array.isRequired, ticker: PropTypes.object.isRequired, setInvoice: PropTypes.func.isRequired, - invoiceModalOpen: PropTypes.bool.isRequired + invoiceModalOpen: PropTypes.bool.isRequired, + currentTicker: PropTypes.object.isRequired } export default Invoices diff --git a/app/routes/activity/components/components/Payments.js b/app/routes/activity/components/components/Payments.js index 442a1996..9117084a 100644 --- a/app/routes/activity/components/components/Payments.js +++ b/app/routes/activity/components/components/Payments.js @@ -108,7 +108,8 @@ Payments.propTypes = { payments: PropTypes.array.isRequired, ticker: PropTypes.object.isRequired, setPayment: PropTypes.func.isRequired, - paymentModalOpen: PropTypes.bool.isRequired + paymentModalOpen: PropTypes.bool.isRequired, + currentTicker: PropTypes.object.isRequired } export default Payments diff --git a/app/routes/app/components/App.js b/app/routes/app/components/App.js index 30d51a02..3a51c121 100644 --- a/app/routes/app/components/App.js +++ b/app/routes/app/components/App.js @@ -6,10 +6,11 @@ import styles from './App.scss' class App extends Component { componentWillMount() { - const { fetchTicker, fetchBalance } = this.props + const { fetchTicker, fetchBalance, fetchInfo } = this.props fetchTicker() fetchBalance() + fetchInfo() } render() { @@ -33,6 +34,8 @@ class App extends Component { children } = this.props + if (!currentTicker) { return