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 --- .../src/app/shared/shared-actor-image/actor-avatar.component.html | 2 +- client/src/app/shared/shared-actor-image/actor-avatar.component.ts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/client/src/app/shared/shared-actor-image/actor-avatar.component.html b/client/src/app/shared/shared-actor-image/actor-avatar.component.html index 13a5385a8..c285b6cc3 100644 --- a/client/src/app/shared/shared-actor-image/actor-avatar.component.html +++ b/client/src/app/shared/shared-actor-image/actor-avatar.component.html @@ -1,7 +1,7 @@ -
+
{{ initial }}
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