Fix message button opens left dm room (#2453)

This commit is contained in:
Ajay Bura 2025-08-19 18:08:46 +05:30 committed by GitHub
parent 789da641c1
commit 09b88d164f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -17,7 +17,7 @@ import to from 'await-to-js';
import { IImageInfo, IThumbnailContent, IVideoInfo } from '../../types/matrix/common'; import { IImageInfo, IThumbnailContent, IVideoInfo } from '../../types/matrix/common';
import { AccountDataEvent } from '../../types/matrix/accountData'; import { AccountDataEvent } from '../../types/matrix/accountData';
import { getStateEvent } from './room'; import { getStateEvent } from './room';
import { StateEvent } from '../../types/matrix/room'; import { Membership, StateEvent } from '../../types/matrix/room';
const DOMAIN_REGEX = /\b(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}\b/; const DOMAIN_REGEX = /\b(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}\b/;
@ -182,7 +182,12 @@ export const eventWithShortcode = (ev: MatrixEvent) =>
export const getDMRoomFor = (mx: MatrixClient, userId: string): Room | undefined => { export const getDMRoomFor = (mx: MatrixClient, userId: string): Room | undefined => {
const dmLikeRooms = mx const dmLikeRooms = mx
.getRooms() .getRooms()
.filter((room) => room.hasEncryptionStateEvent() && room.getMembers().length <= 2); .filter(
(room) =>
room.getMyMembership() === Membership.Join &&
room.hasEncryptionStateEvent() &&
room.getMembers().length <= 2
);
return dmLikeRooms.find((room) => room.getMember(userId)); return dmLikeRooms.find((room) => room.getMember(userId));
}; };