From b5e713105043514db8ab3c5f4b674287701364e8 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 17 Aug 2020 10:47:47 +0200 Subject: [PATCH] only use 1 letter for avatar initial --- src/domain/avatar.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/domain/avatar.js b/src/domain/avatar.js index 9184762b..f94ba3b2 100644 --- a/src/domain/avatar.js +++ b/src/domain/avatar.js @@ -15,18 +15,11 @@ limitations under the License. */ export function avatarInitials(name) { - let words = name.split(" "); - if (words.length === 1) { - words = words[0].split("-"); + let firstChar = name.charAt(0); + if (firstChar === "!" || firstChar === "@" || firstChar === "#") { + firstChar = name.charAt(1); } - words = words.slice(0, 2); - return words.reduce((i, w) => { - let firstChar = w.charAt(0); - if (firstChar === "!" || firstChar === "@" || firstChar === "#") { - firstChar = w.charAt(1); - } - return i + firstChar.toUpperCase(); - }, ""); + return firstChar.toUpperCase(); } /**