From 081a975d2a3b8c63af68c551e09808806821d41b Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Thu, 25 Feb 2016 16:23:38 +0000 Subject: [PATCH] Added ES6 function 'fromCodePoint' to retrive first initial for default avatars that begin with a large unicode character. --- src/components/views/avatars/BaseAvatar.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/views/avatars/BaseAvatar.js b/src/components/views/avatars/BaseAvatar.js index 2a7dcc1c01..3b8f03bd3d 100644 --- a/src/components/views/avatars/BaseAvatar.js +++ b/src/components/views/avatars/BaseAvatar.js @@ -101,9 +101,11 @@ module.exports = React.createClass({ _getInitialLetter: function() { var name = this.props.name; - var initial = name[0]; + //For large characters (exceeding 2 bytes), this function will get the correct character. + //However, this does NOT get the second character correctly if a large character is before it. + var initial = String.fromCodePoint(name.codePointAt(0)); if ((initial === '@' || initial === '#') && name[1]) { - initial = name[1]; + initial = String.fromCodePoint(name.codePointAt(1)); } return initial.toUpperCase(); }, @@ -127,7 +129,7 @@ module.exports = React.createClass({ title={this.props.title} onError={this.onError} width={this.props.width} height={this.props.height} /> - ); + ); } return (