avatar placeholder skip first 05 for initial from pubkey

pull/1344/head
Audric Ackermann 5 years ago
parent 663654ef2c
commit e83912e449
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -101,7 +101,7 @@ export class MessageSearchResult extends React.PureComponent<Props> {
public renderAvatar() {
const { from } = this.props;
const userName = from.phoneNumber || from.profileName;
const userName = from.profileName || from.phoneNumber;
return (
<Avatar

@ -1,21 +1,11 @@
const BAD_CHARACTERS = /[^A-Za-z\s]+/g;
const WHITESPACE = /\s+/g;
function removeNonInitials(name: string) {
return name.replace(BAD_CHARACTERS, '').replace(WHITESPACE, ' ');
}
export function getInitials(name?: string): string | undefined {
if (!name) {
if (!name || !name.length) {
return;
}
const cleaned = removeNonInitials(name);
const parts = cleaned.split(' ');
const initials = parts.map(part => part.trim()[0]);
if (!initials.length) {
return;
if (name.length > 2 && name.startsWith('05')) {
return name[2];
}
return initials[0];
return name[0];
}

Loading…
Cancel
Save