summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2015-11-10 14:47:32 -0500
committerChristopher Speller <crspeller@gmail.com>2015-11-10 14:47:32 -0500
commit81ec1b37419583abdbf395c95977e35e22eb175f (patch)
tree8b1a8470cec32a954cef685db6913f62a8f356be
parentb0fde13147a84ee06e349eeff7d18e5e37980fc2 (diff)
parent1808e8eafad30c5d1bb37924629cda23ea8224d2 (diff)
downloadchat-81ec1b37419583abdbf395c95977e35e22eb175f.tar.gz
chat-81ec1b37419583abdbf395c95977e35e22eb175f.tar.bz2
chat-81ec1b37419583abdbf395c95977e35e22eb175f.zip
Merge pull request #1372 from hmhealey/plt1085
PLT-1085 Updated post components to re-render when stored users change
-rw-r--r--web/react/components/post_body.jsx23
1 files changed, 22 insertions, 1 deletions
diff --git a/web/react/components/post_body.jsx b/web/react/components/post_body.jsx
index 5a157b792..61a0c3e2d 100644
--- a/web/react/components/post_body.jsx
+++ b/web/react/components/post_body.jsx
@@ -16,6 +16,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);
@@ -23,7 +24,13 @@ 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};
+ const profiles = UserStore.getProfiles();
+
+ this.state = {
+ links: linkData.links,
+ message: linkData.text,
+ hasUserProfiles: profiles && Object.keys(profiles).length > 1
+ };
}
getAllChildNodes(nodeIn) {
@@ -47,12 +54,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);
this.setState({links: linkData.links, message: linkData.text});