From 08d263ca9480d9e180c02f656edefb0ad5010e70 Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Wed, 4 Apr 2018 10:43:50 -0500 Subject: [PATCH] fix(contactsform): fix performance hit when searching the network for nodes. limit the amount thats returned so we arent rendering thousands of nodes ever. --- app/reducers/contactsform.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/reducers/contactsform.js b/app/reducers/contactsform.js index 5e55451a..6c9f6f8c 100644 --- a/app/reducers/contactsform.js +++ b/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) } )