diff options
author | Christopher Speller <crspeller@gmail.com> | 2015-11-12 14:55:52 -0500 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2015-11-12 14:55:52 -0500 |
commit | c7fe8510ce663feb26056b34fd18c0e833eb3573 (patch) | |
tree | 0367dc560667b65a9a5a7011fa277af8aecd5c0e /web/react/components/post_body.jsx | |
parent | 931f4f764cbd18f1f5189e03ece83685e4dc6ffa (diff) | |
parent | 10901b4d50db171fa83e0c289d0eb34f4422f156 (diff) | |
download | chat-c7fe8510ce663feb26056b34fd18c0e833eb3573.tar.gz chat-c7fe8510ce663feb26056b34fd18c0e833eb3573.tar.bz2 chat-c7fe8510ce663feb26056b34fd18c0e833eb3573.zip |
Merge branch 'release-1.2'
Diffstat (limited to 'web/react/components/post_body.jsx')
-rw-r--r-- | web/react/components/post_body.jsx | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/web/react/components/post_body.jsx b/web/react/components/post_body.jsx index c57c4490b..1e08a0661 100644 --- a/web/react/components/post_body.jsx +++ b/web/react/components/post_body.jsx @@ -18,6 +18,7 @@ export default class PostBody extends React.Component { this.receivedYoutubeData = false; this.isGifLoading = false; + this.handleUserChange = this.handleUserChange.bind(this); this.parseEmojis = this.parseEmojis.bind(this); this.createEmbed = this.createEmbed.bind(this); this.createGifEmbed = this.createGifEmbed.bind(this); @@ -25,7 +26,14 @@ export default class PostBody extends React.Component { this.createYoutubeEmbed = this.createYoutubeEmbed.bind(this); const linkData = Utils.extractLinks(this.props.post.message); - this.state = {links: linkData.links, message: linkData.text, post: this.props.post}; + const profiles = UserStore.getProfiles(); + + this.state = { + links: linkData.links, + message: linkData.text, + post: this.props.post + hasUserProfiles: profiles && Object.keys(profiles).length > 1 + }; } getAllChildNodes(nodeIn) { @@ -55,12 +63,26 @@ export default class PostBody extends React.Component { componentDidMount() { this.parseEmojis(); + + UserStore.addChangeListener(this.handleUserChange); } componentDidUpdate() { this.parseEmojis(); } + componentWillUnmount() { + UserStore.removeChangeListener(this.handleUserChange); + } + + handleUserChange() { + if (!this.state.hasProfiles) { + const profiles = UserStore.getProfiles(); + + this.setState({hasProfiles: profiles && Object.keys(profiles).length > 1}); + } + } + componentWillReceiveProps(nextProps) { const linkData = Utils.extractLinks(nextProps.post.message); if (this.props.post.filenames.length === 0 && this.state.links && this.state.links.length > 0) { |