mirror of https://github.com/vector-im/riot-web
PR review
parent
39a3d6fdd4
commit
b3638f9169
|
@ -47,7 +47,7 @@ module.exports = React.createClass({
|
||||||
return {
|
return {
|
||||||
// the URLs (if any) to be previewed with a LinkPreviewWidget
|
// the URLs (if any) to be previewed with a LinkPreviewWidget
|
||||||
// inside this TextualBody.
|
// inside this TextualBody.
|
||||||
links: null,
|
links: [],
|
||||||
|
|
||||||
// track whether the preview widget is hidden
|
// track whether the preview widget is hidden
|
||||||
widgetHidden: false,
|
widgetHidden: false,
|
||||||
|
@ -76,6 +76,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
shouldComponentUpdate: function(nextProps, nextState) {
|
shouldComponentUpdate: function(nextProps, nextState) {
|
||||||
// exploit that events are immutable :)
|
// exploit that events are immutable :)
|
||||||
|
// ...and that .links is only ever set in componentDidMount and never changes
|
||||||
return (nextProps.mxEvent.getId() !== this.props.mxEvent.getId() ||
|
return (nextProps.mxEvent.getId() !== this.props.mxEvent.getId() ||
|
||||||
nextProps.highlights !== this.props.highlights ||
|
nextProps.highlights !== this.props.highlights ||
|
||||||
nextProps.highlightLink !== this.props.highlightLink ||
|
nextProps.highlightLink !== this.props.highlightLink ||
|
||||||
|
@ -167,7 +168,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
|
|
||||||
var widgets;
|
var widgets;
|
||||||
if (this.state.links && !this.state.widgetHidden) {
|
if (this.state.links.length && !this.state.widgetHidden) {
|
||||||
var LinkPreviewWidget = sdk.getComponent('rooms.LinkPreviewWidget');
|
var LinkPreviewWidget = sdk.getComponent('rooms.LinkPreviewWidget');
|
||||||
widgets = this.state.links.map((link)=>{
|
widgets = this.state.links.map((link)=>{
|
||||||
return <LinkPreviewWidget
|
return <LinkPreviewWidget
|
||||||
|
|
Loading…
Reference in New Issue