Fetch group data when leaving or joining to update the view

This commit is contained in:
Luke Barnard 2018-04-10 10:03:54 +01:00
parent d02dced246
commit 6f10b5a410
2 changed files with 28 additions and 3 deletions

View file

@ -679,7 +679,7 @@ export default React.createClass({
_onRejectInviteClick: function() { _onRejectInviteClick: function() {
this.setState({membershipBusy: true}); this.setState({membershipBusy: true});
this._matrixClient.leaveGroup(this.props.groupId).then(() => { this._groupStore.leaveGroup().then(() => {
// don't reset membershipBusy here: wait for the membership change to come down the sync // don't reset membershipBusy here: wait for the membership change to come down the sync
}).catch((e) => { }).catch((e) => {
this.setState({membershipBusy: false}); this.setState({membershipBusy: false});
@ -693,7 +693,8 @@ export default React.createClass({
_onJoinClick: function() { _onJoinClick: function() {
this.setState({membershipBusy: true}); this.setState({membershipBusy: true});
this._matrixClient.joinGroup(this.props.groupId).then(() => {
this._groupStore.joinGroup().then(() => {
// don't reset membershipBusy here: wait for the membership change to come down the sync // don't reset membershipBusy here: wait for the membership change to come down the sync
}).catch((e) => { }).catch((e) => {
this.setState({membershipBusy: false}); this.setState({membershipBusy: false});
@ -716,7 +717,7 @@ export default React.createClass({
if (!confirmed) return; if (!confirmed) return;
this.setState({membershipBusy: true}); this.setState({membershipBusy: true});
this._matrixClient.leaveGroup(this.props.groupId).then(() => { this._groupStore.leaveGroup().then(() => {
// don't reset membershipBusy here: wait for the membership change to come down the sync // don't reset membershipBusy here: wait for the membership change to come down the sync
}).catch((e) => { }).catch((e) => {
this.setState({membershipBusy: false}); this.setState({membershipBusy: false});

View file

@ -252,6 +252,8 @@ export default class GroupStore extends EventEmitter {
acceptGroupInvite() { acceptGroupInvite() {
return MatrixClientPeg.get().acceptGroupInvite(this.groupId) return MatrixClientPeg.get().acceptGroupInvite(this.groupId)
// The user should now be able to access (personal) group settings
.then(this._fetchResource.bind(this, GroupStore.STATE_KEY.Summary))
// The user might be able to see more rooms now // The user might be able to see more rooms now
.then(this._fetchResource.bind(this, GroupStore.STATE_KEY.GroupRooms)) .then(this._fetchResource.bind(this, GroupStore.STATE_KEY.GroupRooms))
// The user should now appear as a member // The user should now appear as a member
@ -260,6 +262,28 @@ export default class GroupStore extends EventEmitter {
.then(this._fetchResource.bind(this, GroupStore.STATE_KEY.GroupInvitedMembers)); .then(this._fetchResource.bind(this, GroupStore.STATE_KEY.GroupInvitedMembers));
} }
joinGroup() {
return MatrixClientPeg.get().joinGroup(this.groupId)
// The user should now be able to access (personal) group settings
.then(this._fetchResource.bind(this, GroupStore.STATE_KEY.Summary))
// The user might be able to see more rooms now
.then(this._fetchResource.bind(this, GroupStore.STATE_KEY.GroupRooms))
// The user should now appear as a member
.then(this._fetchResource.bind(this, GroupStore.STATE_KEY.GroupMembers))
// The user should now not appear as an invited member
.then(this._fetchResource.bind(this, GroupStore.STATE_KEY.GroupInvitedMembers));
}
leaveGroup() {
return MatrixClientPeg.get().leaveGroup(this.groupId)
// The user should now not be able to access group settings
.then(this._fetchResource.bind(this, GroupStore.STATE_KEY.Summary))
// The user might only be able to see a subset of rooms now
.then(this._fetchResource.bind(this, GroupStore.STATE_KEY.GroupRooms))
// The user should now not appear as a member
.then(this._fetchResource.bind(this, GroupStore.STATE_KEY.GroupMembers));
}
addRoomToGroupSummary(roomId, categoryId) { addRoomToGroupSummary(roomId, categoryId) {
return MatrixClientPeg.get() return MatrixClientPeg.get()
.addRoomToGroupSummary(this.groupId, roomId, categoryId) .addRoomToGroupSummary(this.groupId, roomId, categoryId)