From bfda4c7c01ea03fbad28c0d2c10b5e528c28e1bb Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Wed, 18 May 2022 14:53:55 +1000 Subject: [PATCH] fix: make sure a convo exists before returning it in search results There is an edge case if you are in the search results page, and delete (or get a convo deleted from the network). The corresponding convo does not exist anymore but the search result selector still tries to extract values from it. This commit fixes that issue by returning early if the corresponding convo is not there anymore --- ts/state/selectors/search.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ts/state/selectors/search.ts b/ts/state/selectors/search.ts index cc6d81aad..b8a963d27 100644 --- a/ts/state/selectors/search.ts +++ b/ts/state/selectors/search.ts @@ -25,6 +25,11 @@ export const getSearchResults = createSelector( searchState.contactsAndGroups.map(id => { const value = lookup[id]; + // on some edges cases, we have an id but no corresponding convo because it matches a query but the conversation was removed. + if (!value) { + return null; + } + // Don't return anything when activeAt is unset (i.e. no current conversations with this user) if (value.activeAt === undefined || value.activeAt === 0) { //activeAt can be 0 when linking device