fixup: rearrange openDMForUser
This commit is contained in:
parent
e32a948d5d
commit
4a1dc55673
1 changed files with 23 additions and 23 deletions
|
@ -75,6 +75,29 @@ async function unverifyUser(matrixClient, userId) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openDMForUser(matrixClient, userId) {
|
||||||
|
const dmRooms = DMRoomMap.shared().getDMRoomsForUserId(userId);
|
||||||
|
const lastActiveRoom = dmRooms.reduce((lastActiveRoom, roomId) => {
|
||||||
|
const room = matrixClient.getRoom(roomId);
|
||||||
|
if (!room || room.getMyMembership() === "leave") {
|
||||||
|
return lastActiveRoom;
|
||||||
|
}
|
||||||
|
if (!lastActiveRoom || lastActiveRoom.getLastActiveTimestamp() < room.getLastActiveTimestamp()) {
|
||||||
|
return room;
|
||||||
|
}
|
||||||
|
return lastActiveRoom;
|
||||||
|
}, null);
|
||||||
|
|
||||||
|
if (lastActiveRoom) {
|
||||||
|
dis.dispatch({
|
||||||
|
action: 'view_room',
|
||||||
|
room_id: lastActiveRoom.roomId,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
createRoom({dmUserId: userId});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function useIsEncrypted(cli, room) {
|
function useIsEncrypted(cli, room) {
|
||||||
const [isEncrypted, setIsEncrypted] = useState(cli.isRoomEncrypted(room.roomId));
|
const [isEncrypted, setIsEncrypted] = useState(cli.isRoomEncrypted(room.roomId));
|
||||||
|
|
||||||
|
@ -112,29 +135,6 @@ const DevicesSection = ({devices, userId, loading}) => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
function openDMForUser(cli, userId) {
|
|
||||||
const dmRooms = DMRoomMap.shared().getDMRoomsForUserId(userId);
|
|
||||||
const lastActiveRoom = dmRooms.reduce((lastActiveRoom, roomId) => {
|
|
||||||
const room = cli.getRoom(roomId);
|
|
||||||
if (!room || room.getMyMembership() === "leave") {
|
|
||||||
return lastActiveRoom;
|
|
||||||
}
|
|
||||||
if (!lastActiveRoom || lastActiveRoom.getLastActiveTimestamp() < room.getLastActiveTimestamp()) {
|
|
||||||
return room;
|
|
||||||
}
|
|
||||||
return lastActiveRoom;
|
|
||||||
}, null);
|
|
||||||
|
|
||||||
if (lastActiveRoom) {
|
|
||||||
dis.dispatch({
|
|
||||||
action: 'view_room',
|
|
||||||
room_id: lastActiveRoom.roomId,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
createRoom({dmUserId: userId});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const UserOptionsSection = withLegacyMatrixClient(({matrixClient: cli, member, isIgnored, canInvite, devices}) => {
|
const UserOptionsSection = withLegacyMatrixClient(({matrixClient: cli, member, isIgnored, canInvite, devices}) => {
|
||||||
let ignoreButton = null;
|
let ignoreButton = null;
|
||||||
let insertPillButton = null;
|
let insertPillButton = null;
|
||||||
|
|
Loading…
Reference in a new issue