Updated post components to re-render after first receiving user profiles
Этот коммит содержится в:
@@ -16,6 +16,7 @@ export default class PostBody extends React.Component {
|
|||||||
this.receivedYoutubeData = false;
|
this.receivedYoutubeData = false;
|
||||||
this.isGifLoading = false;
|
this.isGifLoading = false;
|
||||||
|
|
||||||
|
this.handleUserChange = this.handleUserChange.bind(this);
|
||||||
this.parseEmojis = this.parseEmojis.bind(this);
|
this.parseEmojis = this.parseEmojis.bind(this);
|
||||||
this.createEmbed = this.createEmbed.bind(this);
|
this.createEmbed = this.createEmbed.bind(this);
|
||||||
this.createGifEmbed = this.createGifEmbed.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);
|
this.createYoutubeEmbed = this.createYoutubeEmbed.bind(this);
|
||||||
|
|
||||||
const linkData = Utils.extractLinks(this.props.post.message);
|
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) {
|
getAllChildNodes(nodeIn) {
|
||||||
@@ -47,12 +54,26 @@ export default class PostBody extends React.Component {
|
|||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.parseEmojis();
|
this.parseEmojis();
|
||||||
|
|
||||||
|
UserStore.addChangeListener(this.handleUserChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate() {
|
componentDidUpdate() {
|
||||||
this.parseEmojis();
|
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) {
|
componentWillReceiveProps(nextProps) {
|
||||||
const linkData = Utils.extractLinks(nextProps.post.message);
|
const linkData = Utils.extractLinks(nextProps.post.message);
|
||||||
this.setState({links: linkData.links, message: linkData.text});
|
this.setState({links: linkData.links, message: linkData.text});
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user