Browse Source

fix(contactsform): fix performance hit when searching the network for nodes. limit the amount thats returned so we arent rendering thousands of nodes ever.

renovate/lint-staged-8.x
Jack Mallers 7 years ago
parent
commit
08d263ca94
  1. 7
      app/reducers/contactsform.js

7
app/reducers/contactsform.js

@ -224,7 +224,12 @@ contactFormSelectors.filteredNetworkNodes = createSelector(
// we can ignore the '@' and the host and just grab the pubkey for our search
const query = searchQuery.includes('@') ? searchQuery.split('@')[0] : searchQuery
return filter(nodes, node => node.alias.includes(query) || node.pub_key.includes(query)).sort(contactableFirst)
// list of the nodes
const list = filter(nodes, 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
return list.slice(0, 20)
}
)

Loading…
Cancel
Save