mirror of https://github.com/vector-im/riot-web
Merge pull request #1831 from matrix-org/luke/fix-group-join-or-leave-update
Improve group join/leave feedbackpull/21833/head
commit
74c84addea
|
@ -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._closeSettings();
|
||||
}
|
||||
this.setState({membershipBusy: false});
|
||||
},
|
||||
|
||||
|
@ -562,6 +566,10 @@ export default React.createClass({
|
|||
},
|
||||
|
||||
_onCancelClick: function() {
|
||||
this._closeSettings();
|
||||
},
|
||||
|
||||
_closeSettings() {
|
||||
this.setState({
|
||||
editing: false,
|
||||
profileForm: null,
|
||||
|
@ -678,7 +686,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 +700,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 +724,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});
|
||||
|
@ -989,8 +998,8 @@ export default React.createClass({
|
|||
|
||||
return <div className={membershipContainerClasses}>
|
||||
<div className="mx_GroupView_membershipSubSection">
|
||||
{ /* Empty div for flex alignment */ }
|
||||
<div />
|
||||
{ /* The <div /> is for flex alignment */ }
|
||||
{ this.state.membershipBusy ? <Spinner /> : <div /> }
|
||||
<div className="mx_GroupView_membership_buttonContainer">
|
||||
<AccessibleButton
|
||||
className={membershipButtonClasses}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue