mirror of https://github.com/vector-im/riot-web
Merge pull request #593 from matrix-org/luke/fix-render-1-1-avatars-when-others-leave
Use correct 1-1 room avatar after users leavepull/21833/head
commit
d877384d64
|
@ -109,10 +109,15 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
const mlist = props.room.currentState.members;
|
const mlist = props.room.currentState.members;
|
||||||
const userIds = [];
|
const userIds = [];
|
||||||
|
const leftUserIds = [];
|
||||||
// for .. in optimisation to return early if there are >2 keys
|
// for .. in optimisation to return early if there are >2 keys
|
||||||
for (const uid in mlist) {
|
for (const uid in mlist) {
|
||||||
if (mlist.hasOwnProperty(uid)) {
|
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;
|
||||||
|
@ -134,6 +139,14 @@ module.exports = React.createClass({
|
||||||
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(),
|
||||||
Math.floor(props.width * window.devicePixelRatio),
|
Math.floor(props.width * window.devicePixelRatio),
|
||||||
|
|
Loading…
Reference in New Issue