getIdenticon: Use `conversation.getTitle()` for contact name

This commit is contained in:
Scott Nonnenberg 2021-10-17 14:46:54 -07:00 committed by GitHub
parent 9af523c4fc
commit 43825d3f55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 17 deletions

View File

@ -14,6 +14,7 @@ import {
VerificationOptions,
WhatIsThis,
} from '../model-types.d';
import { getInitials } from '../util/getInitials';
import { AttachmentType, isGIF } from '../types/Attachment';
import { CallMode, CallHistoryDetailsType } from '../types/Calling';
import * as EmbeddedContact from '../types/EmbeddedContact';
@ -4665,21 +4666,6 @@ export class ConversationModel extends window.Backbone
}
}
getInitials(name: string): string | null {
if (!name) {
return null;
}
const cleaned = name.replace(/[^A-Za-z\s]+/g, '').replace(/\s+/g, ' ');
const parts = cleaned.split(' ');
const initials = parts.map(part => part.trim()[0]);
if (!initials.length) {
return null;
}
return initials.slice(0, 2).join('');
}
getColor(): AvatarColorType {
return migrateColor(this.get('color'));
}
@ -4940,9 +4926,9 @@ export class ConversationModel extends window.Backbone
private async getIdenticon(): Promise<string> {
const color = this.getColor();
const name = this.get('name');
const title = this.getTitle();
const content = (name && this.getInitials(name)) || '#';
const content = (title && getInitials(title)) || '#';
const cached = this.cachedIdenticon;
if (cached && cached.content === content && cached.color === color) {