Browse Source
Merge pull request #474 from mrfelton/perf/lodash
Remove lodash dependency
renovate/lint-staged-8.x
Ben Woosley
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with
14 additions and
26 deletions
-
app/components/Contacts/ContactModal.js
-
app/components/Contacts/Network.js
-
app/components/Form/Pay.js
-
app/lnd/methods/channelController.js
-
app/reducers/channels.js
-
app/reducers/contactsform.js
-
app/reducers/payform.js
-
app/routes/activity/components/components/Payment/Payment.js
-
package.json
|
|
@ -1,6 +1,5 @@ |
|
|
|
import React from 'react' |
|
|
|
import PropTypes from 'prop-types' |
|
|
|
import find from 'lodash/find' |
|
|
|
import ReactModal from 'react-modal' |
|
|
|
import FaCircle from 'react-icons/lib/fa/circle' |
|
|
|
import MdClose from 'react-icons/lib/md/close' |
|
|
@ -47,7 +46,7 @@ const ContactModal = ({ |
|
|
|
} |
|
|
|
|
|
|
|
// the remote node for the channel
|
|
|
|
const node = find(channelNodes, { pub_key: channel.remote_pubkey }) |
|
|
|
const node = channelNodes.find(node => node.pub_key === channel.remote_pubkey) |
|
|
|
|
|
|
|
return ( |
|
|
|
<ReactModal |
|
|
|
|
|
@ -1,6 +1,5 @@ |
|
|
|
import React, { Component } from 'react' |
|
|
|
import PropTypes from 'prop-types' |
|
|
|
import find from 'lodash/find' |
|
|
|
import Isvg from 'react-inlinesvg' |
|
|
|
import FaExternalLink from 'react-icons/lib/fa/external-link' |
|
|
|
import FaCircle from 'react-icons/lib/fa/circle' |
|
|
@ -108,7 +107,7 @@ class Network extends Component { |
|
|
|
} |
|
|
|
|
|
|
|
const displayNodeName = displayedChannel => { |
|
|
|
const node = find(nodes, n => displayedChannel.remote_pubkey === n.pub_key) |
|
|
|
const node = nodes.find(n => displayedChannel.remote_pubkey === n.pub_key) |
|
|
|
|
|
|
|
if (node && node.alias.length) { |
|
|
|
return node.alias |
|
|
@ -213,7 +212,7 @@ class Network extends Component { |
|
|
|
{loadingChannelPubkeys.length && |
|
|
|
loadingChannelPubkeys.map(loadingPubkey => { |
|
|
|
// TODO(jimmymow): refactor this out. same logic is in displayNodeName above
|
|
|
|
const node = find(nodes, n => loadingPubkey === n.pub_key) |
|
|
|
const node = nodes.find(n => loadingPubkey === n.pub_key) |
|
|
|
const nodeDisplay = () => { |
|
|
|
if (node && node.alias.length) { |
|
|
|
return node.alias |
|
|
|
|
|
@ -1,6 +1,5 @@ |
|
|
|
import React, { Component } from 'react' |
|
|
|
import PropTypes from 'prop-types' |
|
|
|
import find from 'lodash/find' |
|
|
|
|
|
|
|
import Isvg from 'react-inlinesvg' |
|
|
|
import paperPlane from 'icons/paper_plane.svg' |
|
|
@ -59,7 +58,7 @@ class Pay extends Component { |
|
|
|
} = this.props |
|
|
|
|
|
|
|
const displayNodeName = pubkey => { |
|
|
|
const node = find(nodes, n => n.pub_key === pubkey) |
|
|
|
const node = nodes.find(n => n.pub_key === pubkey) |
|
|
|
|
|
|
|
if (node && node.alias.length) { |
|
|
|
return node.alias |
|
|
|
|
|
@ -1,10 +1,9 @@ |
|
|
|
import find from 'lodash/find' |
|
|
|
import { listPeers, connectPeer } from './peersController' |
|
|
|
import pushopenchannel from '../push/openchannel' |
|
|
|
|
|
|
|
function ensurePeerConnected(lnd, pubkey, host) { |
|
|
|
return listPeers(lnd).then(({ peers }) => { |
|
|
|
const peer = find(peers, { pub_key: pubkey }) |
|
|
|
const peer = peers.find(candidatePeer => candidatePeer.pub_key === pubkey) |
|
|
|
if (peer) { |
|
|
|
return peer |
|
|
|
} |
|
|
|
|
|
@ -1,6 +1,5 @@ |
|
|
|
import { createSelector } from 'reselect' |
|
|
|
import { ipcRenderer } from 'electron' |
|
|
|
import filter from 'lodash/filter' |
|
|
|
import { btc } from 'utils' |
|
|
|
import { showNotification } from 'notifications' |
|
|
|
import { requestSuggestedNodes } from '../api' |
|
|
@ -483,7 +482,7 @@ channelsSelectors.channelNodes = createSelector( |
|
|
|
(channels, nodes) => { |
|
|
|
const chanPubkeys = channels.map(channel => channel.remote_pubkey) |
|
|
|
|
|
|
|
return filter(nodes, node => chanPubkeys.includes(node.pub_key)) |
|
|
|
return nodes.filter(node => chanPubkeys.includes(node.pub_key)) |
|
|
|
} |
|
|
|
) |
|
|
|
|
|
|
|
|
|
@ -1,6 +1,4 @@ |
|
|
|
import { createSelector } from 'reselect' |
|
|
|
import filter from 'lodash/filter' |
|
|
|
import isEmpty from 'lodash/isEmpty' |
|
|
|
|
|
|
|
import { tickerSelectors } from './ticker' |
|
|
|
import { btc } from '../utils' |
|
|
@ -234,10 +232,9 @@ contactFormSelectors.filteredNetworkNodes = createSelector( |
|
|
|
const query = searchQuery.includes('@') ? searchQuery.split('@')[0] : searchQuery |
|
|
|
|
|
|
|
// list of the nodes
|
|
|
|
const list = filter( |
|
|
|
nodes, |
|
|
|
node => node.alias.includes(query) || node.pub_key.includes(query) |
|
|
|
).sort(contactableFirst) |
|
|
|
const list = nodes |
|
|
|
.filter(node => node.alias.includes(query) || node.pub_key.includes(query)) |
|
|
|
.sort(contactableFirst) |
|
|
|
|
|
|
|
// if we don't limit the nodes returned then we take a huge performance hit
|
|
|
|
// rendering thousands of nodes potentially, so we just render 20 for the time being
|
|
|
@ -270,7 +267,7 @@ contactFormSelectors.manualFormIsValid = createSelector(manualSearchQuerySelecto |
|
|
|
} |
|
|
|
return { |
|
|
|
errors, |
|
|
|
isValid: isEmpty(errors) |
|
|
|
isValid: Object.keys(errors).length === 0 |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
@ -1,8 +1,6 @@ |
|
|
|
import { createSelector } from 'reselect' |
|
|
|
import bitcoin from 'bitcoinjs-lib' |
|
|
|
|
|
|
|
import isEmpty from 'lodash/isEmpty' |
|
|
|
|
|
|
|
import { setFormType } from './form' |
|
|
|
import { tickerSelectors } from './ticker' |
|
|
|
import { infoSelectors } from './info' |
|
|
@ -267,9 +265,9 @@ payFormSelectors.payFormIsValid = createSelector( |
|
|
|
|
|
|
|
return { |
|
|
|
errors, |
|
|
|
amountIsValid: isEmpty(errors.amount), |
|
|
|
payInputIsValid: isEmpty(errors.payInput), |
|
|
|
isValid: isEmpty(errors) |
|
|
|
amountIsValid: !errors.amount, |
|
|
|
payInputIsValid: !errors.payInput, |
|
|
|
isValid: Object.keys(errors).length === 0 |
|
|
|
} |
|
|
|
} |
|
|
|
) |
|
|
|
|
|
@ -1,6 +1,5 @@ |
|
|
|
import React from 'react' |
|
|
|
import PropTypes from 'prop-types' |
|
|
|
import find from 'lodash/find' |
|
|
|
import Moment from 'react-moment' |
|
|
|
import { btc } from 'utils' |
|
|
|
|
|
|
@ -9,7 +8,7 @@ import styles from '../Activity.scss' |
|
|
|
|
|
|
|
const Payment = ({ payment, ticker, currentTicker, showActivityModal, nodes, currencyName }) => { |
|
|
|
const displayNodeName = pubkey => { |
|
|
|
const node = find(nodes, n => pubkey === n.pub_key) |
|
|
|
const node = nodes.find(n => pubkey === n.pub_key) |
|
|
|
|
|
|
|
if (node && node.alias.length) { |
|
|
|
return node.alias |
|
|
|
|
|
@ -229,7 +229,6 @@ |
|
|
|
"electron-store": "^2.0.0", |
|
|
|
"font-awesome": "^4.7.0", |
|
|
|
"history": "^4.6.3", |
|
|
|
"lodash": "^4.17.10", |
|
|
|
"moment": "^2.22.2", |
|
|
|
"prop-types": "^15.5.10", |
|
|
|
"qrcode.react": "0.8.0", |
|
|
|