summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2016-03-31 13:01:05 -0400
committerHarrison Healey <harrisonmhealey@gmail.com>2016-03-31 13:01:05 -0400
commit36f611fac48536f26770357de8d5b6767bd46d2f (patch)
treeb92ca8dc6e9593eee054f7bd73e185735b6a6209
parent720947e17e4e7820dcae6c5e25b5fe8485a7fc6c (diff)
parent54a064de98f43c55bed429867493e6f5c7e97379 (diff)
downloadchat-36f611fac48536f26770357de8d5b6767bd46d2f.tar.gz
chat-36f611fac48536f26770357de8d5b6767bd46d2f.tar.bz2
chat-36f611fac48536f26770357de8d5b6767bd46d2f.zip
Merge pull request #2594 from mattermost/plt-2476
PLT-2476 Fixing username display in center channel
-rw-r--r--webapp/components/channel_view.jsx19
-rw-r--r--webapp/components/invite_member_modal.jsx18
-rw-r--r--webapp/components/logged_in.jsx18
-rw-r--r--webapp/components/permalink_view.jsx25
-rw-r--r--webapp/components/posts_view_container.jsx12
5 files changed, 38 insertions, 54 deletions
diff --git a/webapp/components/channel_view.jsx b/webapp/components/channel_view.jsx
index 54d796ac1..4cca5aa98 100644
--- a/webapp/components/channel_view.jsx
+++ b/webapp/components/channel_view.jsx
@@ -8,7 +8,6 @@ import PostsViewContainer from 'components/posts_view_container.jsx';
import CreatePost from 'components/create_post.jsx';
import ChannelStore from 'stores/channel_store.jsx';
-import UserStore from 'stores/user_store.jsx';
export default class ChannelView extends React.Component {
constructor(props) {
@@ -23,14 +22,12 @@ export default class ChannelView extends React.Component {
getStateFromStores(props) {
const channel = ChannelStore.getByName(props.params.channel);
const channelId = channel ? channel.id : '';
- const profiles = JSON.parse(JSON.stringify(UserStore.getProfiles()));
return {
- channelId,
- profiles
+ channelId
};
}
isStateValid() {
- return this.state.channelId !== '' && this.state.profiles;
+ return this.state.channelId !== '';
}
updateState() {
this.setState(this.getStateFromStores(this.props));
@@ -44,13 +41,6 @@ export default class ChannelView extends React.Component {
componentWillReceiveProps(nextProps) {
this.setState(this.getStateFromStores(nextProps));
}
- shouldComponentUpdate(nextProps, nextState) {
- if (nextState.channelId !== this.state.channelId) {
- return true;
- }
-
- return false;
- }
render() {
return (
<div
@@ -60,7 +50,7 @@ export default class ChannelView extends React.Component {
<ChannelHeader
channelId={this.state.channelId}
/>
- <PostsViewContainer profiles={this.state.profiles}/>
+ <PostsViewContainer profiles={this.props.profiles}/>
<div
className='post-create__container'
id='post-create'
@@ -75,5 +65,6 @@ ChannelView.defaultProps = {
};
ChannelView.propTypes = {
- params: React.PropTypes.object.isRequired
+ params: React.PropTypes.object.isRequired,
+ profiles: React.PropTypes.object
};
diff --git a/webapp/components/invite_member_modal.jsx b/webapp/components/invite_member_modal.jsx
index 1f8fd6133..81c3a9629 100644
--- a/webapp/components/invite_member_modal.jsx
+++ b/webapp/components/invite_member_modal.jsx
@@ -50,6 +50,7 @@ class InviteMemberModal extends React.Component {
constructor(props) {
super(props);
+ this.teamChange = this.teamChange.bind(this);
this.handleToggle = this.handleToggle.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
this.handleHide = this.handleHide.bind(this);
@@ -68,16 +69,27 @@ class InviteMemberModal extends React.Component {
emailEnabled: global.window.mm_config.SendEmailNotifications === 'true',
userCreationEnabled: global.window.mm_config.EnableUserCreation === 'true',
showConfirmModal: false,
- isSendingEmails: false
+ isSendingEmails: false,
+ teamType: null
};
}
+ teamChange() {
+ const team = TeamStore.getCurrent();
+ const teamType = team ? team.type : null;
+ this.setState({
+ teamType
+ });
+ }
+
componentDidMount() {
ModalStore.addModalListener(ActionTypes.TOGGLE_INVITE_MEMBER_MODAL, this.handleToggle);
+ TeamStore.addChangeListener(this.teamChange);
}
componentWillUnmount() {
ModalStore.removeModalListener(ActionTypes.TOGGLE_INVITE_MEMBER_MODAL, this.handleToggle);
+ TeamStore.removeChangeListener(this.teamChange);
}
handleToggle(value) {
@@ -224,7 +236,7 @@ class InviteMemberModal extends React.Component {
var currentUser = UserStore.getCurrentUser();
const {formatMessage} = this.props.intl;
- if (currentUser != null) {
+ if (currentUser != null && this.state.teamType != null) {
var inviteSections = [];
var inviteIds = this.state.inviteIds;
for (var i = 0; i < inviteIds.length; i++) {
@@ -398,7 +410,7 @@ class InviteMemberModal extends React.Component {
);
} else if (this.state.userCreationEnabled) {
var teamInviteLink = null;
- if (currentUser && TeamStore.getCurrent().type === 'O') {
+ if (currentUser && this.state.teamType === 'O') {
var link = (
<a
href='#'
diff --git a/webapp/components/logged_in.jsx b/webapp/components/logged_in.jsx
index 3b44f5940..0c4571083 100644
--- a/webapp/components/logged_in.jsx
+++ b/webapp/components/logged_in.jsx
@@ -47,11 +47,12 @@ export default class LoggedIn extends React.Component {
this.onUserChanged = this.onUserChanged.bind(this);
this.state = {
- user: null
+ user: null,
+ profiles: null
};
}
isValidState() {
- return this.state.user != null;
+ return this.state.user != null && this.state.profiles != null;
}
onUserChanged() {
// Grab the current user
@@ -84,7 +85,13 @@ export default class LoggedIn extends React.Component {
browserHistory.push(Utils.getTeamURLFromAddressBar() + '/tutorial');
}
- this.setState({user});
+ // Get profiles
+ const profiles = UserStore.getProfiles();
+
+ this.setState({
+ user,
+ profiles
+ });
}
componentWillMount() {
// Emit view action
@@ -232,7 +239,10 @@ export default class LoggedIn extends React.Component {
</div>
</div>
<div className='row main'>
- {this.props.center}
+ {React.cloneElement(this.props.center, {
+ user: this.state.user,
+ profiles: this.state.profiles
+ })}
</div>
</div>
);
diff --git a/webapp/components/permalink_view.jsx b/webapp/components/permalink_view.jsx
index 2ebe52356..2c32d643d 100644
--- a/webapp/components/permalink_view.jsx
+++ b/webapp/components/permalink_view.jsx
@@ -7,7 +7,6 @@ import ChannelHeader from 'components/channel_header.jsx';
import PostFocusView from 'components/post_focus_view.jsx';
import ChannelStore from 'stores/channel_store.jsx';
-import UserStore from 'stores/user_store.jsx';
import TeamStore from 'stores/team_store.jsx';
import {Link} from 'react-router';
@@ -30,17 +29,15 @@ export default class PermalinkView extends React.Component {
const channelName = channel ? channel.name : '';
const team = TeamStore.getCurrent();
const teamName = team ? team.name : '';
- const profiles = JSON.parse(JSON.stringify(UserStore.getProfiles()));
return {
channelId,
channelName,
- profiles,
teamName,
postId
};
}
isStateValid() {
- return this.state.channelId !== '' && this.state.profiles && this.state.teamName;
+ return this.state.channelId !== '' && this.state.teamName;
}
updateState() {
this.setState(this.getStateFromStores(this.props));
@@ -56,21 +53,6 @@ export default class PermalinkView extends React.Component {
componentWillReceiveProps(nextProps) {
this.setState(this.getStateFromStores(nextProps));
}
- shouldComponentUpdate(nextProps, nextState) {
- if (nextState.postId !== this.state.postId) {
- return true;
- }
-
- if (nextState.channelId !== this.state.channelId) {
- return true;
- }
-
- if (nextState.teamName !== this.state.teamName) {
- return true;
- }
-
- return false;
- }
render() {
if (!this.isStateValid()) {
return null;
@@ -83,7 +65,7 @@ export default class PermalinkView extends React.Component {
<ChannelHeader
channelId={this.state.channelId}
/>
- <PostFocusView profiles={this.state.profiles}/>
+ <PostFocusView profiles={this.props.profiles}/>
<div
id='archive-link-home'
>
@@ -106,5 +88,6 @@ PermalinkView.defaultProps = {
};
PermalinkView.propTypes = {
- params: React.PropTypes.object.isRequired
+ params: React.PropTypes.object.isRequired,
+ profiles: React.PropTypes.object
};
diff --git a/webapp/components/posts_view_container.jsx b/webapp/components/posts_view_container.jsx
index 7e334d4b0..a49c77f8d 100644
--- a/webapp/components/posts_view_container.jsx
+++ b/webapp/components/posts_view_container.jsx
@@ -8,7 +8,6 @@ import ChannelStore from 'stores/channel_store.jsx';
import PostStore from 'stores/post_store.jsx';
import UserStore from 'stores/user_store.jsx';
-import * as Utils from 'utils/utils.jsx';
import * as GlobalActions from 'action_creators/global_actions.jsx';
import Constants from 'utils/constants.jsx';
@@ -158,17 +157,6 @@ export default class PostsViewContainer extends React.Component {
this.setState({scrollType: PostsView.SCROLL_TYPE_FREE});
}
}
- shouldComponentUpdate(nextProps, nextState) {
- if (!Utils.areObjectsEqual(this.state, nextState)) {
- return true;
- }
-
- if (!Utils.areObjectsEqual(this.props, nextProps)) {
- return true;
- }
-
- return false;
- }
render() {
const postLists = this.state.postLists;
const channels = this.state.channels;