Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2786 from matrix-org/travis/you-are-not-alone
Browse files Browse the repository at this point in the history
Ensure freshly invited members don't count towards the alone warning
  • Loading branch information
turt2live authored Mar 14, 2019
2 parents f2421d9 + a551bf4 commit 5409db4
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/components/structures/RoomView.js
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ module.exports = React.createClass({
return;
}

this._updateRoomMembers();
this._updateRoomMembers(member);
},

onMyMembership: function(room, membership, oldMembership) {
Expand All @@ -798,16 +798,24 @@ module.exports = React.createClass({

// rate limited because a power level change will emit an event for every
// member in the room.
_updateRoomMembers: new rate_limited_func(function() {
_updateRoomMembers: new rate_limited_func(function(dueToMember) {
// a member state changed in this room
// refresh the conf call notification state
this._updateConfCallNotification();
this._updateDMState();
this._checkIfAlone(this.state.room);

let memberCountInfluence = 0;
if (dueToMember && dueToMember.membership === "invite" && this.state.room.getInvitedMemberCount() === 0) {
// A member got invited, but the room hasn't detected that change yet. Influence the member
// count by 1 to counteract this.
memberCountInfluence = 1;
}
this._checkIfAlone(this.state.room, memberCountInfluence);

this._updateE2EStatus(this.state.room);
}, 500),

_checkIfAlone: function(room) {
_checkIfAlone: function(room, countInfluence) {
let warnedAboutLonelyRoom = false;
if (localStorage) {
warnedAboutLonelyRoom = localStorage.getItem('mx_user_alone_warned_' + this.state.room.roomId);
Expand All @@ -817,7 +825,8 @@ module.exports = React.createClass({
return;
}

const joinedOrInvitedMemberCount = room.getJoinedMemberCount() + room.getInvitedMemberCount();
let joinedOrInvitedMemberCount = room.getJoinedMemberCount() + room.getInvitedMemberCount();
if (countInfluence) joinedOrInvitedMemberCount += countInfluence;
this.setState({isAlone: joinedOrInvitedMemberCount === 1});
},

Expand Down

0 comments on commit 5409db4

Please sign in to comment.