feat: contact names starting with a number go into the unknown section

pull/3137/head
yougotwill 9 months ago
parent 87f050ae55
commit 242a4ae52f

@ -95,15 +95,25 @@ const ContactListItemSection = () => {
let currentChar = ''; let currentChar = '';
// if the item is a string we consider it to be a break of that string // if the item is a string we consider it to be a break of that string
const directContactsByNameWithBreaks: Array<DirectContactsByNameType | string> = []; const directContactsByNameWithBreaks: Array<DirectContactsByNameType | string> = [];
const directContactsStartingWithANumber: Array<DirectContactsByNameType | string> = [];
directContactsByName.forEach(m => { directContactsByName.forEach(m => {
if (m.displayName && m.displayName[0].toLowerCase() !== currentChar) { if (
m.displayName &&
m.displayName[0].toLowerCase() !== currentChar &&
!m.displayName[0].match(/^[0-9]+$/)
) {
currentChar = m.displayName[0].toLowerCase(); currentChar = m.displayName[0].toLowerCase();
directContactsByNameWithBreaks.push(currentChar.toUpperCase()); directContactsByNameWithBreaks.push(currentChar.toUpperCase());
} else if (!m.displayName && currentChar !== unknownSection) { } else if (!m.displayName && currentChar !== unknownSection) {
currentChar = unknownSection; currentChar = unknownSection;
directContactsByNameWithBreaks.push('#'); directContactsByNameWithBreaks.push('#');
} }
directContactsByNameWithBreaks.push(m);
if (m.displayName && !!m.displayName[0].match(/^[0-9]+$/)) {
directContactsStartingWithANumber.push(m);
} else {
directContactsByNameWithBreaks.push(m);
}
}); });
directContactsByNameWithBreaks.unshift({ directContactsByNameWithBreaks.unshift({
@ -111,6 +121,13 @@ const ContactListItemSection = () => {
displayName: window.i18n('noteToSelf'), displayName: window.i18n('noteToSelf'),
}); });
if (directContactsStartingWithANumber.length) {
if (currentChar !== unknownSection) {
directContactsByNameWithBreaks.push('#');
}
directContactsByNameWithBreaks.push(...directContactsStartingWithANumber);
}
const length = Number(directContactsByNameWithBreaks.length); const length = Number(directContactsByNameWithBreaks.length);
return ( return (

@ -93,8 +93,8 @@ export const getSearchResultsList = createSelector([getSearchResults], searchSta
m => m.displayName?.toLowerCase() m => m.displayName?.toLowerCase()
); );
const idsWithNoDisplayNames = sortBy( const idsWithNoDisplayNamesOrStartingWithANumber = sortBy(
remove(idsWithNameAndType, m => !m.displayName), remove(idsWithNameAndType, m => !m.displayName || m.displayName[0].match(/^[0-9]+$/)),
m => m.contactConvoId m => m.contactConvoId
); );
@ -120,8 +120,9 @@ export const getSearchResultsList = createSelector([getSearchResults], searchSta
builtList.unshift(...groupsAndCommunities); builtList.unshift(...groupsAndCommunities);
if (idsWithNoDisplayNames.length) { if (idsWithNoDisplayNamesOrStartingWithANumber.length) {
builtList.push('#', ...idsWithNoDisplayNames); // builtList.push('#');
builtList.push(...idsWithNoDisplayNamesOrStartingWithANumber);
} }
if (usIndex !== -1) { if (usIndex !== -1) {

Loading…
Cancel
Save