From 25e6a0e5705e27223b98a46fe0d84dd78412702a Mon Sep 17 00:00:00 2001 From: Robin Townsend Date: Fri, 16 Jul 2021 14:19:36 -0400 Subject: [PATCH 1/2] Match colors of room and user avatars in DMs Signed-off-by: Robin Townsend --- src/components/views/avatars/RoomAvatar.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/views/avatars/RoomAvatar.tsx b/src/components/views/avatars/RoomAvatar.tsx index 8ac8de8233..a07990c3bb 100644 --- a/src/components/views/avatars/RoomAvatar.tsx +++ b/src/components/views/avatars/RoomAvatar.tsx @@ -22,6 +22,7 @@ import ImageView from '../elements/ImageView'; import { MatrixClientPeg } from '../../../MatrixClientPeg'; import Modal from '../../../Modal'; import * as Avatar from '../../../Avatar'; +import DMRoomMap from "../../../utils/DMRoomMap"; import { replaceableComponent } from "../../../utils/replaceableComponent"; import { mediaFromMxc } from "../../../customisations/Media"; import { IOOBData } from '../../../stores/ThreepidInviteStore'; @@ -131,11 +132,14 @@ export default class RoomAvatar extends React.Component { const { room, oobData, viewAvatarOnClick, onClick, ...otherProps } = this.props; const roomName = room ? room.name : oobData.name; + // If the room is a DM, we use the other user's ID for the color hash + // in order to match the room avatar with their avatar + const idName = room ? (DMRoomMap.shared().getUserIdForRoomId(room.roomId) ?? room.roomId) : null; return ( From eefadf6a4653d0acbe9858a8960b64d2e52ac196 Mon Sep 17 00:00:00 2001 From: Robin Townsend Date: Fri, 16 Jul 2021 15:30:26 -0400 Subject: [PATCH 2/2] Fix tests Signed-off-by: Robin Townsend --- test/components/views/messages/TextualBody-test.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/components/views/messages/TextualBody-test.js b/test/components/views/messages/TextualBody-test.js index fd11a9d46b..85a02aad7b 100644 --- a/test/components/views/messages/TextualBody-test.js +++ b/test/components/views/messages/TextualBody-test.js @@ -23,6 +23,7 @@ import { mkEvent, mkStubRoom } from "../../../test-utils"; import { MatrixClientPeg } from "../../../../src/MatrixClientPeg"; import * as languageHandler from "../../../../src/languageHandler"; import * as TestUtils from "../../../test-utils"; +import DMRoomMap from "../../../../src/utils/DMRoomMap"; const _TextualBody = sdk.getComponent("views.messages.TextualBody"); const TextualBody = TestUtils.wrapInMatrixClientContext(_TextualBody); @@ -41,6 +42,7 @@ describe("", () => { isGuest: () => false, mxcUrlToHttp: (s) => s, }; + DMRoomMap.makeShared(); const ev = mkEvent({ type: "m.room.message", @@ -66,6 +68,7 @@ describe("", () => { isGuest: () => false, mxcUrlToHttp: (s) => s, }; + DMRoomMap.makeShared(); const ev = mkEvent({ type: "m.room.message", @@ -92,6 +95,7 @@ describe("", () => { isGuest: () => false, mxcUrlToHttp: (s) => s, }; + DMRoomMap.makeShared(); }); it("simple message renders as expected", () => { @@ -146,6 +150,7 @@ describe("", () => { isGuest: () => false, mxcUrlToHttp: (s) => s, }; + DMRoomMap.makeShared(); }); it("italics, bold, underline and strikethrough render as expected", () => { @@ -292,6 +297,7 @@ describe("", () => { isGuest: () => false, mxcUrlToHttp: (s) => s, }; + DMRoomMap.makeShared(); const ev = mkEvent({ type: "m.room.message",