diff options
author | Saturnino Abril <saturnino.abril@gmail.com> | 2017-06-21 05:08:09 +0800 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2017-06-20 17:08:09 -0400 |
commit | 6e2e1c3bbb12be059426d895dc1f6d4062d10532 (patch) | |
tree | bdacd7ef6e7bec66447a0255b80698643a183ecb /webapp/components/post_view/post_attachment_opengraph | |
parent | 14054a532d090632f7505ebf38a24f24645a8656 (diff) | |
download | chat-6e2e1c3bbb12be059426d895dc1f6d4062d10532.tar.gz chat-6e2e1c3bbb12be059426d895dc1f6d4062d10532.tar.bz2 chat-6e2e1c3bbb12be059426d895dc1f6d4062d10532.zip |
fix /expand and /collapse for link previews (#6676)
* fix /expand and /collapse for link previews
* make props.openGraphData not required for PostAttachmentOpenGraph component
Diffstat (limited to 'webapp/components/post_view/post_attachment_opengraph')
-rw-r--r-- | webapp/components/post_view/post_attachment_opengraph/post_attachment_opengraph.jsx | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/webapp/components/post_view/post_attachment_opengraph/post_attachment_opengraph.jsx b/webapp/components/post_view/post_attachment_opengraph/post_attachment_opengraph.jsx index dbf8f6049..e3ddcc6d5 100644 --- a/webapp/components/post_view/post_attachment_opengraph/post_attachment_opengraph.jsx +++ b/webapp/components/post_view/post_attachment_opengraph/post_attachment_opengraph.jsx @@ -18,7 +18,7 @@ export default class PostAttachmentOpenGraph extends React.PureComponent { /** * The open graph data to render */ - openGraphData: PropTypes.object.isRequired, + openGraphData: PropTypes.object, /** * Set to collapse the preview @@ -50,17 +50,16 @@ export default class PostAttachmentOpenGraph extends React.PureComponent { this.smallImageContainer = null; this.smallImageElement = null; + this.IMAGE_LOADED = { + LOADING: 'loading', + YES: 'yes', + ERROR: 'error' + }; + this.fetchData = this.fetchData.bind(this); this.toggleImageVisibility = this.toggleImageVisibility.bind(this); this.onImageLoad = this.onImageLoad.bind(this); this.onImageError = this.onImageError.bind(this); - this.truncateText = this.truncateText.bind(this); - } - - IMAGE_LOADED = { - LOADING: 'loading', - YES: 'yes', - ERROR: 'error' } componentWillMount() { @@ -76,6 +75,11 @@ export default class PostAttachmentOpenGraph extends React.PureComponent { if (nextProps.link !== this.props.link) { this.fetchData(nextProps.link); } + if (nextProps.previewCollapsed !== this.props.previewCollapsed) { + this.setState({ + imageVisible: nextProps.previewCollapsed.startsWith('false') + }); + } } fetchData(url) { |