fix automatic DM avatar with functional members (#12157)

* fix automatic DM avatar with functional members

* add tests for functional members

* add snapshot for functional members avatar test

* update snapshot for functional members avatar test

* restore mocks after each functional members avatar test

* refactor DecoratedRoomAvatar-test

---------

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
Co-authored-by: R Midhun Suresh <hi@midhun.dev>
This commit is contained in:
Kim Brose 2024-03-03 12:01:00 +01:00 committed by GitHub
parent 5a0537b7eb
commit 65bfc920a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 74 additions and 7 deletions

View file

@ -29,6 +29,7 @@ import { MatrixClientPeg } from "../../../MatrixClientPeg";
import { _t } from "../../../languageHandler";
import DMRoomMap from "../../../utils/DMRoomMap";
import { IOOBData } from "../../../stores/ThreepidInviteStore";
import { getJoinedNonFunctionalMembers } from "../../../utils/room/getJoinedNonFunctionalMembers";
interface IProps {
room: Room;
@ -158,7 +159,7 @@ export default class DecoratedRoomAvatar extends React.PureComponent<IProps, ISt
// We look at the DMRoomMap and not the tag here so that we don't exclude DMs in Favourites
const otherUserId = DMRoomMap.shared().getUserIdForRoomId(this.props.room.roomId);
if (otherUserId && this.props.room.getJoinedMemberCount() === 2) {
if (otherUserId && getJoinedNonFunctionalMembers(this.props.room).length === 2) {
// Track presence, if available
if (isPresenceEnabled(this.props.room.client)) {
this.dmUser = MatrixClientPeg.safeGet().getUser(otherUserId);