mirror of
https://github.com/element-hq/element-web
synced 2024-11-27 19:56:47 +03:00
Merge pull request #347 from matrix-org/matthew/fix-race-on-new-room-invitelist
Fix race when creating rooms where invite list can be blank
This commit is contained in:
commit
2b7ade9ef5
2 changed files with 33 additions and 10 deletions
|
@ -37,17 +37,14 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillMount: function() {
|
componentWillMount: function() {
|
||||||
this._room = MatrixClientPeg.get().getRoom(this.props.roomId);
|
var cli = MatrixClientPeg.get();
|
||||||
|
cli.on("RoomState.members", this.onRoomStateMember);
|
||||||
|
|
||||||
this._emailEntity = null;
|
this._emailEntity = null;
|
||||||
// Load the complete user list for inviting new users
|
|
||||||
// TODO: Keep this list bleeding-edge up-to-date. Practically speaking,
|
// we have to update the list whenever membership changes
|
||||||
// it will do for now not being updated as random new users join different
|
// particularly to avoid bug https://github.com/vector-im/vector-web/issues/1813
|
||||||
// rooms as this list will be reloaded every room swap.
|
this._updateList();
|
||||||
if (this._room) {
|
|
||||||
this._userList = MatrixClientPeg.get().getUsers().filter((u) => {
|
|
||||||
return !this._room.hasMembershipState(u.userId, "join");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
|
@ -55,6 +52,28 @@ module.exports = React.createClass({
|
||||||
this.onSearchQueryChanged('');
|
this.onSearchQueryChanged('');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
componentWillUnmount: function() {
|
||||||
|
var cli = MatrixClientPeg.get();
|
||||||
|
if (cli) {
|
||||||
|
cli.removeListener("RoomState.members", this.onRoomStateMember);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_updateList: function() {
|
||||||
|
this._room = MatrixClientPeg.get().getRoom(this.props.roomId);
|
||||||
|
// Load the complete user list for inviting new users
|
||||||
|
if (this._room) {
|
||||||
|
this._userList = MatrixClientPeg.get().getUsers().filter((u) => {
|
||||||
|
return (!this._room.hasMembershipState(u.userId, "join") &&
|
||||||
|
!this._room.hasMembershipState(u.userId, "invite"));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onRoomStateMember: function(ev, state, member) {
|
||||||
|
this._updateList();
|
||||||
|
},
|
||||||
|
|
||||||
onInvite: function(ev) {
|
onInvite: function(ev) {
|
||||||
this.props.onInvite(this._input);
|
this.props.onInvite(this._input);
|
||||||
},
|
},
|
||||||
|
|
|
@ -69,6 +69,10 @@ function createRoom(opts) {
|
||||||
return client.createRoom(createOpts).finally(function() {
|
return client.createRoom(createOpts).finally(function() {
|
||||||
modal.close();
|
modal.close();
|
||||||
}).then(function(res) {
|
}).then(function(res) {
|
||||||
|
// NB createRoom doesn't block on the client seeing the echo that the
|
||||||
|
// room has been created, so we race here with the client knowing that
|
||||||
|
// the room exists, causing things like
|
||||||
|
// https://github.com/vector-im/vector-web/issues/1813
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'view_room',
|
action: 'view_room',
|
||||||
room_id: res.room_id
|
room_id: res.room_id
|
||||||
|
|
Loading…
Reference in a new issue