From 54a064de98f43c55bed429867493e6f5c7e97379 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Thu, 31 Mar 2016 10:54:40 -0400 Subject: Fixing username display in center channel --- webapp/components/channel_view.jsx | 19 +++++-------------- webapp/components/invite_member_modal.jsx | 18 +++++++++++++++--- webapp/components/logged_in.jsx | 18 ++++++++++++++---- webapp/components/permalink_view.jsx | 25 ++++--------------------- webapp/components/posts_view_container.jsx | 12 ------------ 5 files changed, 38 insertions(+), 54 deletions(-) (limited to 'webapp') 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 (
- +
- {this.props.center} + {React.cloneElement(this.props.center, { + user: this.state.user, + profiles: this.state.profiles + })}
); 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 { - +