mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-16 13:14:58 +08:00
Fix settings direct chat
We were expecting this function to return a string user ID, but it returned a user object Make it return a user ID and add jsdoc to say what it returns. Fixes https://github.com/vector-im/riot-web/issues/8180
This commit is contained in:
parent
fcd234f286
commit
4248a20885
@ -159,6 +159,10 @@ export function setDMRoom(roomId, userId) {
|
|||||||
/**
|
/**
|
||||||
* Given a room, estimate which of its members is likely to
|
* Given a room, estimate which of its members is likely to
|
||||||
* be the target if the room were a DM room and return that user.
|
* be the target if the room were a DM room and return that user.
|
||||||
|
*
|
||||||
|
* @param {Object} room Target room
|
||||||
|
* @param {string} myUserId User ID of the current user
|
||||||
|
* @returns {string} User ID of the user that the room is probably a DM with
|
||||||
*/
|
*/
|
||||||
function guessDMRoomTargetId(room, myUserId) {
|
function guessDMRoomTargetId(room, myUserId) {
|
||||||
let oldestTs;
|
let oldestTs;
|
||||||
@ -173,7 +177,7 @@ function guessDMRoomTargetId(room, myUserId) {
|
|||||||
oldestTs = user.events.member.getTs();
|
oldestTs = user.events.member.getTs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (oldestUser) return oldestUser;
|
if (oldestUser) return oldestUser.userId;
|
||||||
|
|
||||||
// if there are no joined members other than us, use the oldest member
|
// if there are no joined members other than us, use the oldest member
|
||||||
for (const user of room.currentState.getMembers()) {
|
for (const user of room.currentState.getMembers()) {
|
||||||
@ -186,5 +190,5 @@ function guessDMRoomTargetId(room, myUserId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (oldestUser === undefined) return myUserId;
|
if (oldestUser === undefined) return myUserId;
|
||||||
return oldestUser;
|
return oldestUser.userId;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user