incorporate PR feedback
This commit is contained in:
parent
1125c62505
commit
1d8b08040e
5 changed files with 42 additions and 41 deletions
|
@ -66,6 +66,7 @@ module.exports = React.createClass({
|
|||
// lazy-load the hidden state of the preview widget from localstorage
|
||||
if (global.localStorage) {
|
||||
var hidden = global.localStorage.getItem("hide_preview_" + this.props.mxEvent.getId());
|
||||
// XXX: we're gutwrenching mxEvent here by setting our own custom property on it
|
||||
this.props.mxEvent.widgetHidden = hidden;
|
||||
this.setState({ widgetHidden: hidden });
|
||||
}
|
||||
|
@ -75,18 +76,6 @@ module.exports = React.createClass({
|
|||
HtmlUtils.highlightDom(ReactDOM.findDOMNode(this));
|
||||
},
|
||||
|
||||
findLink: function(nodes) {
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
var node = nodes[i];
|
||||
if (node.tagName === "A" && node.getAttribute("href")) {
|
||||
return node;
|
||||
}
|
||||
else if (node.children && node.children.length) {
|
||||
return this.findLink(node.children)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
shouldComponentUpdate: function(nextProps, nextState) {
|
||||
// exploit that events are immutable :)
|
||||
return (nextProps.mxEvent.getId() !== this.props.mxEvent.getId() ||
|
||||
|
@ -100,7 +89,20 @@ module.exports = React.createClass({
|
|||
this.setState({ widgetHidden: nextProps.mxEvent.widgetHidden });
|
||||
},
|
||||
|
||||
findLink: function(nodes) {
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
var node = nodes[i];
|
||||
if (node.tagName === "A" && node.getAttribute("href")) {
|
||||
return node;
|
||||
}
|
||||
else if (node.children && node.children.length) {
|
||||
return this.findLink(node.children)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onCancelClick: function(event) {
|
||||
// XXX: we're gutwrenching mxEvent here by setting our own custom property on it
|
||||
this.props.mxEvent.widgetHidden = true;
|
||||
this.setState({ widgetHidden: true });
|
||||
// FIXME: persist this somewhere smarter than local storage
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue