diff options
author | Christopher Speller <crspeller@gmail.com> | 2016-02-08 07:26:10 -0500 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-03-14 00:38:25 -0400 |
commit | d7cdcf082fab6c0cb7c2fe4bed821bd1a8000e69 (patch) | |
tree | 49a0de30cdc2ac461e72a242ae9a5593fcd6c8b9 /web/react/components/channel_invite_modal.jsx | |
parent | 08f0800adef926e8b69ebea70e4995b89f5c3f3c (diff) | |
download | chat-d7cdcf082fab6c0cb7c2fe4bed821bd1a8000e69.tar.gz chat-d7cdcf082fab6c0cb7c2fe4bed821bd1a8000e69.tar.bz2 chat-d7cdcf082fab6c0cb7c2fe4bed821bd1a8000e69.zip |
Convering client to react-router.
Diffstat (limited to 'web/react/components/channel_invite_modal.jsx')
-rw-r--r-- | web/react/components/channel_invite_modal.jsx | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/web/react/components/channel_invite_modal.jsx b/web/react/components/channel_invite_modal.jsx index 6c8d51abb..4157812a9 100644 --- a/web/react/components/channel_invite_modal.jsx +++ b/web/react/components/channel_invite_modal.jsx @@ -4,8 +4,8 @@ import FilteredUserList from './filtered_user_list.jsx'; import LoadingScreen from './loading_screen.jsx'; -import UserStore from '../stores/user_store.jsx'; import ChannelStore from '../stores/channel_store.jsx'; +import UserStore from '../stores/user_store.jsx'; import * as Utils from '../utils/utils.jsx'; import * as Client from '../utils/client.jsx'; @@ -16,18 +16,15 @@ import {FormattedMessage} from 'mm-intl'; const Modal = ReactBootstrap.Modal; export default class ChannelInviteModal extends React.Component { - constructor() { - super(); + constructor(props) { + super(props); this.onListenerChange = this.onListenerChange.bind(this); this.handleInvite = this.handleInvite.bind(this); - + this.getStateFromStores = this.getStateFromStores.bind(this); this.createInviteButton = this.createInviteButton.bind(this); - // the state gets populated when the modal is shown - this.state = { - loading: true - }; + this.state = this.getStateFromStores(); } shouldComponentUpdate(nextProps, nextState) { if (!this.props.show && !nextProps.show) { @@ -63,6 +60,20 @@ export default class ChannelInviteModal extends React.Component { }; } + const currentUser = UserStore.getCurrentUser(); + if (!currentUser) { + return { + loading: true + }; + } + + const currentMember = ChannelStore.getCurrentMember(); + if (!currentMember) { + return { + loading: true + }; + } + const memberIds = extraInfo.members.map((user) => user.id); var nonmembers = []; @@ -78,7 +89,9 @@ export default class ChannelInviteModal extends React.Component { return { nonmembers, - loading: false + loading: false, + currentUser, + currentMember }; } componentWillReceiveProps(nextProps) { @@ -93,6 +106,11 @@ export default class ChannelInviteModal extends React.Component { UserStore.removeChangeListener(this.onListenerChange); } } + componentWillUnmount() { + ChannelStore.removeExtraInfoChangeListener(this.onListenerChange); + ChannelStore.removeChangeListener(this.onListenerChange); + UserStore.removeChangeListener(this.onListenerChange); + } onListenerChange() { var newState = this.getStateFromStores(); if (!Utils.areObjectsEqual(this.state, newState)) { @@ -144,7 +162,6 @@ export default class ChannelInviteModal extends React.Component { if (Utils.windowHeight() <= 1200) { maxHeight = Utils.windowHeight() - 300; } - content = ( <FilteredUserList style={{maxHeight}} |