Make notification initials consistent with everything else (#3006)

Make notification initials consistent with Avatar component
This commit is contained in:
Herohtar 2019-01-02 16:34:18 -06:00 committed by Scott Nonnenberg
parent 9ffe7c5836
commit a21d63e450

View file

@ -1771,6 +1771,21 @@
}
},
getInitials(name) {
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('');
},
isPrivate() {
return this.get('type') === 'private';
},
@ -1802,7 +1817,7 @@
} else if (this.isPrivate()) {
return {
color,
content: title ? title.trim()[0] : '#',
content: this.getInitials(title) || '#',
};
}
return { url: 'images/group_default.png', color };