From f41efa52a412272928ba90e06c9a9a9c471d1ca3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 28 Feb 2022 16:44:11 +0100 Subject: Fix avatar with username starting with numbers --- client/src/app/shared/shared-actor-image/actor-avatar.component.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'client/src/app/shared/shared-actor-image/actor-avatar.component.ts') diff --git a/client/src/app/shared/shared-actor-image/actor-avatar.component.ts b/client/src/app/shared/shared-actor-image/actor-avatar.component.ts index bc7e8a096..b2e1ef46e 100644 --- a/client/src/app/shared/shared-actor-image/actor-avatar.component.ts +++ b/client/src/app/shared/shared-actor-image/actor-avatar.component.ts @@ -89,9 +89,11 @@ export class ActorAvatarComponent { } private getColorTheme () { + const initialLowercase = this.initial.toLowerCase() + // Keep consistency with CSS const themes = { - abc: 'blue', + '0123456789abc': 'blue', def: 'green', ghi: 'purple', jkl: 'gray', @@ -102,7 +104,7 @@ export class ActorAvatarComponent { } const theme = Object.keys(themes) - .find(chars => chars.includes(this.initial)) + .find(chars => chars.includes(initialLowercase)) return themes[theme] } -- cgit v1.2.3