From bb7f94251d9b536157dbb566b622eb4cea7c659a Mon Sep 17 00:00:00 2001 From: Julien DAUPHANT Date: Thu, 13 Apr 2023 22:04:32 +0200 Subject: [PATCH] Fix room avatars take default colors --- patches/patches.json | 12 ++++++++++-- .../matrix-react-sdk+3.69.1.patch | 13 +++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 patches/room-avatars-default-colors/matrix-react-sdk+3.69.1.patch diff --git a/patches/patches.json b/patches/patches.json index 9428153a8a..31d2d97811 100644 --- a/patches/patches.json +++ b/patches/patches.json @@ -202,5 +202,13 @@ "files": [ "src/stores/RoomViewStore.tsx" ] - } -} \ No newline at end of file + }, + "room-avatars-default-colors": { + "github-issue": "https://github.com/tchapgouv/tchap-web-v4/issues/282", + "package": "matrix-react-sdk", + "files": [ + "src/Avatar.ts" + ] + } + +} diff --git a/patches/room-avatars-default-colors/matrix-react-sdk+3.69.1.patch b/patches/room-avatars-default-colors/matrix-react-sdk+3.69.1.patch new file mode 100644 index 0000000000..124525bd3d --- /dev/null +++ b/patches/room-avatars-default-colors/matrix-react-sdk+3.69.1.patch @@ -0,0 +1,13 @@ +diff --git a/node_modules/matrix-react-sdk/src/Avatar.ts b/node_modules/matrix-react-sdk/src/Avatar.ts +index 88c80ef..a023ba0 100644 +--- a/node_modules/matrix-react-sdk/src/Avatar.ts ++++ b/node_modules/matrix-react-sdk/src/Avatar.ts +@@ -96,7 +96,7 @@ export function defaultAvatarUrlForString(s: string): string { + const colorIndex = total % defaultColors.length; + // overwritten color value in custom themes + const cssVariable = `--avatar-background-colors_${colorIndex}`; +- const cssValue = document.body.style.getPropertyValue(cssVariable); ++ const cssValue = getComputedStyle(document.body).getPropertyValue(cssVariable); + const color = cssValue || defaultColors[colorIndex]; + let dataUrl = colorToDataURLCache.get(color); + if (!dataUrl) {