From 42141f7da7c00367f1adbb47ef2be5474f974b11 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Tue, 10 Apr 2018 10:03:54 +0100 Subject: [PATCH 1/4] Fetch group data when leaving or joining to update the view --- src/components/structures/GroupView.js | 7 ++++--- src/stores/GroupStore.js | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/components/structures/GroupView.js b/src/components/structures/GroupView.js index 2cb791b689..65f6a5b0b1 100644 --- a/src/components/structures/GroupView.js +++ b/src/components/structures/GroupView.js @@ -678,7 +678,7 @@ export default React.createClass({ _onRejectInviteClick: function() { 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 }).catch((e) => { this.setState({membershipBusy: false}); @@ -692,7 +692,8 @@ export default React.createClass({ _onJoinClick: function() { 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 }).catch((e) => { this.setState({membershipBusy: false}); @@ -715,7 +716,7 @@ export default React.createClass({ if (!confirmed) return; 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 }).catch((e) => { this.setState({membershipBusy: false}); diff --git a/src/stores/GroupStore.js b/src/stores/GroupStore.js index 2ea69b61aa..d4f0b09ff9 100644 --- a/src/stores/GroupStore.js +++ b/src/stores/GroupStore.js @@ -252,6 +252,8 @@ export default class GroupStore extends EventEmitter { acceptGroupInvite() { 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 .then(this._fetchResource.bind(this, GroupStore.STATE_KEY.GroupRooms)) // 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)); } + 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) { return MatrixClientPeg.get() .addRoomToGroupSummary(this.groupId, roomId, categoryId) From 0681df71b07851150ced0d7b6282ffc324fdce6d Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Tue, 10 Apr 2018 11:49:35 +0100 Subject: [PATCH 2/4] Hide settings after leaving a group --- src/components/structures/GroupView.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/structures/GroupView.js b/src/components/structures/GroupView.js index 65f6a5b0b1..0ec216dea2 100644 --- a/src/components/structures/GroupView.js +++ b/src/components/structures/GroupView.js @@ -466,6 +466,10 @@ export default React.createClass({ _onGroupMyMembership: function(group) { if (group.groupId !== this.props.groupId) return; + if (group.myMembership === 'leave') { + // Leave settings - the user might have clicked the "Leave" button + this._onCancelClick(); + } this.setState({membershipBusy: false}); }, From 24d4df87d197bbe628956fc6ca24f53c5f42a902 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Tue, 10 Apr 2018 11:49:59 +0100 Subject: [PATCH 3/4] Show membership spinner next to Leave/Join button when leaving/joining --- src/components/structures/GroupView.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/structures/GroupView.js b/src/components/structures/GroupView.js index 0ec216dea2..e2b93992e3 100644 --- a/src/components/structures/GroupView.js +++ b/src/components/structures/GroupView.js @@ -994,8 +994,8 @@ export default React.createClass({ return
- { /* Empty div for flex alignment */ } -
+ { /* The
is for flex alignment */ } + { this.state.membershipBusy ? :
}
Date: Tue, 10 Apr 2018 13:28:42 +0100 Subject: [PATCH 4/4] Factor out `_closeSettings` for cleanliness --- src/components/structures/GroupView.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/structures/GroupView.js b/src/components/structures/GroupView.js index e2b93992e3..e725483d29 100644 --- a/src/components/structures/GroupView.js +++ b/src/components/structures/GroupView.js @@ -468,7 +468,7 @@ export default React.createClass({ if (group.myMembership === 'leave') { // Leave settings - the user might have clicked the "Leave" button - this._onCancelClick(); + this._closeSettings(); } this.setState({membershipBusy: false}); }, @@ -566,6 +566,10 @@ export default React.createClass({ }, _onCancelClick: function() { + this._closeSettings(); + }, + + _closeSettings() { this.setState({ editing: false, profileForm: null,