Skip to content

Commit

Permalink
Fix room avatars take default colors
Browse files Browse the repository at this point in the history
  • Loading branch information
jdauphant committed Apr 13, 2023
1 parent f4e7650 commit 9d5be9c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
12 changes: 10 additions & 2 deletions patches/patches.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,13 @@
"files": [
"src/stores/RoomViewStore.tsx"
]
}
}
},
"add-translations-for-server-errors": {
"github-issue": "https://github.com/tchapgouv/tchap-web-v4/issues/282",
"package": "matrix-react-sdk",
"files": [
"src/Avatar.ts"
]
}

}
13 changes: 13 additions & 0 deletions patches/room-avatars-default-colors/matrix-react-sdk+3.69.1.patch
Original file line number Diff line number Diff line change
@@ -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) {

0 comments on commit 9d5be9c

Please sign in to comment.