diff options
-rw-r--r-- | vnext/src/components/Thread.js | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/vnext/src/components/Thread.js b/vnext/src/components/Thread.js index d53617b2..7464ca7f 100644 --- a/vnext/src/components/Thread.js +++ b/vnext/src/components/Thread.js @@ -14,9 +14,9 @@ import { format } from '../utils/embed'; export default class Thread extends React.Component { constructor(props) { super(props); - const { msg } = this.props.location.state || {} + const { msg } = (this.props.location.state || {}); this.state = { - msg: msg, + msg: msg || {}, replies: [], active: 0 }; @@ -55,7 +55,7 @@ export default class Thread extends React.Component { }); } loaded() { - return (this.state.replies && this.state.replies.length > 0) || ( 'mid' in this.state.msg && !('replies' in this.state.msg)); + return (this.state.replies && this.state.replies.length > 0) || ('mid' in this.state.msg && !('replies' in this.state.msg)); } setActive(msg, event) { this.setState({ @@ -87,7 +87,7 @@ export default class Thread extends React.Component { <ul id="0"> <li className="msg msgthread"> { - this.state.msg ? ( + msg.mid ? ( <Message data={msg} visitor={this.props.visitor}> {this.state.active === (msg.rid || 0) && <MessageInput data={msg} onSend={this.postComment} />} <Recommendations src={msg.recommendations} /> @@ -100,13 +100,13 @@ export default class Thread extends React.Component { </ul> { <React.Fragment> - <div className="title2"> - { - this.props.visitor.uid > 0 && + { + this.props.visitor.uid > 0 && msg.mid && + <div className="title2"> <img style={{ display: 'none' }} src={`https://api.juick.com/thread/mark_read/${msg.mid}-${msg.rid || 0}.gif?hash=${this.props.visitor.hash}`} /> - } - <h2>{msg.replies && `Replies (${msg.replies})`}</h2> - </div> + <h2>{msg.replies && `Replies (${msg.replies})`}</h2> + </div> + } {this.loaded() ? ( <ul id="replies"> { @@ -133,9 +133,9 @@ export default class Thread extends React.Component { </time> </a> {msg.replyto > 0 && - ( - <a href={`#${msg.replyto}`}> in reply to {msg.to.uname} </a> - )} + ( + <a href={`#${msg.replyto}`}> in reply to {msg.to.uname} </a> + )} </div> </div> <div className="msg-txt"><p dangerouslySetInnerHTML={{ __html: format(msg.body, msg.mid, (msg.tags || []).indexOf('code') >= 0) }}></p></div> @@ -149,12 +149,12 @@ export default class Thread extends React.Component { { this.props.visitor.uid > 0 ? ( <React.Fragment> - {this.state.active === msg.rid || <button onClick={this.setActive.bind(this, msg)} className="badge"><Icon name="ei-envelope" size="s"/>Reply</button>} + {this.state.active === msg.rid || <button onClick={this.setActive.bind(this, msg)} className="badge"><Icon name="ei-envelope" size="s" />Reply</button>} {this.state.active === msg.rid && <MessageInput data={msg} onSend={this.postComment} />} </React.Fragment> ) : ( <React.Fragment> - <span> · </span>{this.state.active === msg.rid || <button className="a-login">Reply</button> } + <span> · </span>{this.state.active === msg.rid || <button className="a-login">Reply</button>} </React.Fragment> ) } |