diff options
author | Christopher Speller <crspeller@gmail.com> | 2016-03-14 00:56:37 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-03-14 00:56:37 -0400 |
commit | 975159b52ac6bf0ee6b2d5b73d2391b2e0c6e165 (patch) | |
tree | a0852f9faf6de9962b5478ed3f1bbaccd71062c0 /web/react/components/channel_invite_modal.jsx | |
parent | 160e1a8bea6d8280ef3b41a4a9f80674b75f3eb0 (diff) | |
parent | d7cdcf082fab6c0cb7c2fe4bed821bd1a8000e69 (diff) | |
download | chat-975159b52ac6bf0ee6b2d5b73d2391b2e0c6e165.tar.gz chat-975159b52ac6bf0ee6b2d5b73d2391b2e0c6e165.tar.bz2 chat-975159b52ac6bf0ee6b2d5b73d2391b2e0c6e165.zip |
Merge pull request #2331 from mattermost/plt-1680
PLT-1680 Converting client to react-router. Stage 1
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}} |