From 2dbcfe565a24528091d9e3d4373e06688efd917f Mon Sep 17 00:00:00 2001 From: William Grant Date: Wed, 12 Jun 2024 17:50:15 +1000 Subject: [PATCH] fix: remove unecessary length check on idsWithDisplayNames --- ts/state/selectors/search.ts | 41 ++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/ts/state/selectors/search.ts b/ts/state/selectors/search.ts index 37a7d8d1f..91daa04d5 100644 --- a/ts/state/selectors/search.ts +++ b/ts/state/selectors/search.ts @@ -90,29 +90,28 @@ export const getSearchResultsList = createSelector([getSearchResults], searchSta idsAndDisplayNames.filter(m => Boolean(m.displayName)), m => m.displayName?.toLowerCase() ); - if (idsWithDisplayNames.length) { - // add a break wherever needed - let currentChar = ''; - for (let i = 0; i < idsWithDisplayNames.length; i++) { - const m = idsWithDisplayNames[i]; - if (m.contactConvoId === us) { - usIndex = i; - continue; - } - if ( - idsWithDisplayNames.length > 1 && - m.displayName && - m.displayName[0].toLowerCase() !== currentChar - ) { - currentChar = m.displayName[0].toLowerCase(); - builtList.push(currentChar.toUpperCase()); - } - builtList.push(m); - } - if (usIndex !== -1) { - builtList.unshift({ contactConvoId: us, displayName: window.i18n('noteToSelf') }); + // add a break wherever needed + let currentChar = ''; + for (let i = 0; i < idsWithDisplayNames.length; i++) { + const m = idsWithDisplayNames[i]; + if (m.contactConvoId === us) { + usIndex = i; + continue; + } + if ( + idsWithDisplayNames.length > 1 && + m.displayName && + m.displayName[0].toLowerCase() !== currentChar + ) { + currentChar = m.displayName[0].toLowerCase(); + builtList.push(currentChar.toUpperCase()); } + builtList.push(m); + } + + if (usIndex !== -1) { + builtList.unshift({ contactConvoId: us, displayName: window.i18n('noteToSelf') }); } const idsWithNoDisplayNames = sortBy(