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

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

Loading…
Cancel
Save