summaryrefslogtreecommitdiffstats
path: root/web/react/components/user_settings/user_settings_modal.jsx
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-02-08 07:26:10 -0500
committerChristopher Speller <crspeller@gmail.com>2016-03-14 00:38:25 -0400
commitd7cdcf082fab6c0cb7c2fe4bed821bd1a8000e69 (patch)
tree49a0de30cdc2ac461e72a242ae9a5593fcd6c8b9 /web/react/components/user_settings/user_settings_modal.jsx
parent08f0800adef926e8b69ebea70e4995b89f5c3f3c (diff)
downloadchat-d7cdcf082fab6c0cb7c2fe4bed821bd1a8000e69.tar.gz
chat-d7cdcf082fab6c0cb7c2fe4bed821bd1a8000e69.tar.bz2
chat-d7cdcf082fab6c0cb7c2fe4bed821bd1a8000e69.zip
Convering client to react-router.
Diffstat (limited to 'web/react/components/user_settings/user_settings_modal.jsx')
-rw-r--r--web/react/components/user_settings/user_settings_modal.jsx16
1 files changed, 13 insertions, 3 deletions
diff --git a/web/react/components/user_settings/user_settings_modal.jsx b/web/react/components/user_settings/user_settings_modal.jsx
index fa3415988..0c4a3d526 100644
--- a/web/react/components/user_settings/user_settings_modal.jsx
+++ b/web/react/components/user_settings/user_settings_modal.jsx
@@ -73,27 +73,35 @@ class UserSettingsModal extends React.Component {
this.updateTab = this.updateTab.bind(this);
this.updateSection = this.updateSection.bind(this);
+ this.onUserChanged = this.onUserChanged.bind(this);
this.state = {
active_tab: 'general',
active_section: '',
showConfirmModal: false,
- enforceFocus: true
+ enforceFocus: true,
+ currentUser: UserStore.getCurrentUser()
};
this.requireConfirm = false;
}
+ onUserChanged() {
+ this.setState({currentUser: UserStore.getCurrentUser()});
+ }
+
componentDidMount() {
if (this.props.show) {
this.handleShow();
}
+ UserStore.addChangeListener(this.onUserChanged);
}
componentDidUpdate(prevProps) {
if (this.props.show && !prevProps.show) {
this.handleShow();
}
+ UserStore.removeChangeListener(this.onUserChanged);
}
handleShow() {
@@ -235,8 +243,10 @@ class UserSettingsModal extends React.Component {
render() {
const {formatMessage} = this.props.intl;
- var currentUser = UserStore.getCurrentUser();
- var isAdmin = Utils.isAdmin(currentUser.roles);
+ if (this.state.currentUser == null) {
+ return (<div/>);
+ }
+ var isAdmin = Utils.isAdmin(this.state.currentUser.roles);
var tabs = [];
tabs.push({name: 'general', uiName: formatMessage(holders.general), icon: 'glyphicon glyphicon-cog'});