mirror of
https://github.com/element-hq/element-web.git
synced 2024-12-15 18:21:38 +03:00
Handle the case where the other 1-1 user left
This commit is contained in:
parent
10017522e2
commit
583f86eb06
1 changed files with 16 additions and 2 deletions
|
@ -84,10 +84,15 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
var mlist = props.room.currentState.members;
|
var mlist = props.room.currentState.members;
|
||||||
var userIds = [];
|
var userIds = [];
|
||||||
|
var leftUserIds = [];
|
||||||
// for .. in optimisation to return early if there are >2 keys
|
// for .. in optimisation to return early if there are >2 keys
|
||||||
for (var uid in mlist) {
|
for (var uid in mlist) {
|
||||||
if (mlist.hasOwnProperty(uid) && ["join", "invite"].includes(mlist[uid].membership)) {
|
if (mlist.hasOwnProperty(uid)) {
|
||||||
userIds.push(uid);
|
if (["join", "invite"].includes(mlist[uid].membership)) {
|
||||||
|
userIds.push(uid);
|
||||||
|
} else {
|
||||||
|
leftUserIds.push(uid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (userIds.length > 2) {
|
if (userIds.length > 2) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -101,12 +106,21 @@ module.exports = React.createClass({
|
||||||
} else {
|
} else {
|
||||||
theOtherGuy = mlist[userIds[0]];
|
theOtherGuy = mlist[userIds[0]];
|
||||||
}
|
}
|
||||||
|
|
||||||
return theOtherGuy.getAvatarUrl(
|
return theOtherGuy.getAvatarUrl(
|
||||||
MatrixClientPeg.get().getHomeserverUrl(),
|
MatrixClientPeg.get().getHomeserverUrl(),
|
||||||
props.width, props.height, props.resizeMethod,
|
props.width, props.height, props.resizeMethod,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
} else if (userIds.length == 1) {
|
} else if (userIds.length == 1) {
|
||||||
|
// The other 1-1 user left, leaving just the current user, so show the left user's avatar
|
||||||
|
if (leftUserIds.length === 1) {
|
||||||
|
return mlist[leftUserIds[0]].getAvatarUrl(
|
||||||
|
MatrixClientPeg.get().getHomeserverUrl(),
|
||||||
|
props.width, props.height, props.resizeMethod,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
return mlist[userIds[0]].getAvatarUrl(
|
return mlist[userIds[0]].getAvatarUrl(
|
||||||
MatrixClientPeg.get().getHomeserverUrl(),
|
MatrixClientPeg.get().getHomeserverUrl(),
|
||||||
props.width, props.height, props.resizeMethod,
|
props.width, props.height, props.resizeMethod,
|
||||||
|
|
Loading…
Reference in a new issue