From ef3d7994114a004b0c02bc5693673b5d3d4e30cc Mon Sep 17 00:00:00 2001 From: or-else Date: Tue, 11 Sep 2018 15:42:05 +0300 Subject: [PATCH] merge chat list and found contacts --- src/webapp.jsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/webapp.jsx b/src/webapp.jsx index 70511587..923d092d 100644 --- a/src/webapp.jsx +++ b/src/webapp.jsx @@ -4714,14 +4714,18 @@ class TinodeWeb extends React.Component { } tnFndSubsUpdated() { - let contacts = []; + let foundContacts = []; // Don't attempt to create P2P topics which already exist. Server will reject the duplicates. this.state.tinode.getFndTopic().contacts((s) => { - contacts.push(s); + foundContacts.push(s); }); + let merged = {}; + for (const c of foundContacts.concat(this.state.chatList)) { + merged[c.topic] = c; + } this.setState({ - searchResults: contacts, - searchableContacts: mergeContacts(contacts, this.state.chatList) + searchResults: foundContacts, + searchableContacts: Object.values(merged) }); }