diff options
author | Joram Wilander <jwawilander@gmail.com> | 2015-12-04 08:21:39 -0500 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2015-12-04 08:21:39 -0500 |
commit | 04727955cd73864d23be9da7fb999d23e93a20e0 (patch) | |
tree | 60f7b58a68693a7b80853ec88f533264c104e9ae /web/react/components/channel_invite_modal.jsx | |
parent | 93db32da7b97f4d4c10afc17f48c2221eefb54c7 (diff) | |
parent | bc173ebcb47f60d5e99081156575a8ace98fe168 (diff) | |
download | chat-04727955cd73864d23be9da7fb999d23e93a20e0.tar.gz chat-04727955cd73864d23be9da7fb999d23e93a20e0.tar.bz2 chat-04727955cd73864d23be9da7fb999d23e93a20e0.zip |
Merge pull request #1600 from hmhealey/plt1152
PLT-1152 Fix cross-contamination between invite member modals
Diffstat (limited to 'web/react/components/channel_invite_modal.jsx')
-rw-r--r-- | web/react/components/channel_invite_modal.jsx | 38 |
1 files changed, 9 insertions, 29 deletions
diff --git a/web/react/components/channel_invite_modal.jsx b/web/react/components/channel_invite_modal.jsx index 0518ccb86..56e2e53f9 100644 --- a/web/react/components/channel_invite_modal.jsx +++ b/web/react/components/channel_invite_modal.jsx @@ -53,15 +53,8 @@ export default class ChannelInviteModal extends React.Component { return a.username.localeCompare(b.username); }); - var channelName = ''; - if (ChannelStore.getCurrent()) { - channelName = ChannelStore.getCurrent().display_name; - } - return { nonmembers, - memberIds, - channelName, loading }; } @@ -94,28 +87,14 @@ export default class ChannelInviteModal extends React.Component { } } handleInvite(userId) { - // Make sure the user isn't already a member of the channel - if (this.state.memberIds.indexOf(userId) > -1) { - return; - } - var data = {}; data.user_id = userId; - Client.addChannelMember(ChannelStore.getCurrentId(), data, + Client.addChannelMember( + this.props.channel.id, + data, () => { - var nonmembers = this.state.nonmembers; - var memberIds = this.state.memberIds; - - for (var i = 0; i < nonmembers.length; i++) { - if (userId === nonmembers[i].id) { - nonmembers[i].invited = true; - memberIds.push(userId); - break; - } - } - - this.setState({inviteError: null, memberIds, nonmembers}); + this.setState({inviteError: null}); AsyncClient.getChannelExtraInfo(); }, (err) => { @@ -157,10 +136,10 @@ export default class ChannelInviteModal extends React.Component { <Modal dialogClassName='more-modal' show={this.props.show} - onHide={this.props.onModalDismissed} + onHide={this.props.onHide} > <Modal.Header closeButton={true}> - <Modal.Title>{'Add New Members to '}<span className='name'>{this.state.channelName}</span></Modal.Title> + <Modal.Title>{'Add New Members to '}<span className='name'>{this.props.channel.display_nam}</span></Modal.Title> </Modal.Header> <Modal.Body ref='modalBody' @@ -173,7 +152,7 @@ export default class ChannelInviteModal extends React.Component { <button type='button' className='btn btn-default' - onClick={this.props.onModalDismissed} + onClick={this.props.onHide} > {'Close'} </button> @@ -185,5 +164,6 @@ export default class ChannelInviteModal extends React.Component { ChannelInviteModal.propTypes = { show: React.PropTypes.bool.isRequired, - onModalDismissed: React.PropTypes.func.isRequired + onHide: React.PropTypes.func.isRequired, + channel: React.PropTypes.object.isRequired }; |