You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-07 10:46:24 +03:00
Update createRoom to support creating DM rooms
* Make ChatInviteDialog and MemberInfo createRoom use it * Fix bug in setDMRoom
This commit is contained in:
16
src/Rooms.js
16
src/Rooms.js
@@ -93,14 +93,12 @@ export function setDMRoom(roomId, userId) {
|
||||
|
||||
if (mDirectEvent !== undefined) dmRoomMap = mDirectEvent.getContent();
|
||||
|
||||
// remove it from the lists of any others users
|
||||
// (it can only be a DM room for one person)
|
||||
for (const thisUserId of Object.keys(dmRoomMap)) {
|
||||
const roomList = dmRoomMap[thisUserId];
|
||||
|
||||
if (thisUserId == userId) {
|
||||
if (roomList.indexOf(roomId) == -1) {
|
||||
roomList.push(roomId);
|
||||
}
|
||||
} else {
|
||||
if (thisUserId != userId) {
|
||||
const indexOfRoom = roomList.indexOf(roomId);
|
||||
if (indexOfRoom > -1) {
|
||||
roomList.splice(indexOfRoom, 1);
|
||||
@@ -108,6 +106,14 @@ export function setDMRoom(roomId, userId) {
|
||||
}
|
||||
}
|
||||
|
||||
// now add it, if it's not already there
|
||||
const roomList = dmRoomMap[userId] || [];
|
||||
if (roomList.indexOf(roomId) == -1) {
|
||||
roomList.push(roomId);
|
||||
}
|
||||
dmRoomMap[userId] = roomList;
|
||||
|
||||
|
||||
return MatrixClientPeg.get().setAccountData('m.direct', dmRoomMap);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user