aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/components
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-06-22 00:44:23 +0300
committerGravatar Vitaly Takmazov2023-01-13 10:37:53 +0300
commitc2470acb2f19c1834c8a99b1e9f1da43304bec87 (patch)
treea9d8974bf2cc6ae182df5d2758a35507a647b29b /vnext/src/components
parent29f599dc9d6d72247841ae441a6cda95b273270c (diff)
fix thread refreshing
Diffstat (limited to 'vnext/src/components')
-rw-r--r--vnext/src/components/Thread.js30
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}&nbsp;</a>
- )}
+ (
+ <a href={`#${msg.replyto}`}> in reply to {msg.to.uname}&nbsp;</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>&nbsp;&middot;&nbsp;</span>{this.state.active === msg.rid || <button className="a-login">Reply</button> }
+ <span>&nbsp;&middot;&nbsp;</span>{this.state.active === msg.rid || <button className="a-login">Reply</button>}
</React.Fragment>
)
}