aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/components/Thread.js
diff options
context:
space:
mode:
Diffstat (limited to 'vnext/src/components/Thread.js')
-rw-r--r--vnext/src/components/Thread.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/vnext/src/components/Thread.js b/vnext/src/components/Thread.js
index d61fd87f..c1dc915b 100644
--- a/vnext/src/components/Thread.js
+++ b/vnext/src/components/Thread.js
@@ -22,13 +22,17 @@ export default function Thread(props) {
const [loading, setLoading] = useState(false);
const [active, setActive] = useState(0);
useEffect(() => {
- props.connection.addEventListener('msg', onReply);
+ if (props.connection) {
+ props.connection.addEventListener('msg', onReply);
+ }
setActive(0);
loadReplies();
return () => {
- props.connection.removeEventListener('msg', onReply);
+ if (props.connection) {
+ props.connection.removeEventListener('msg', onReply);
+ }
}
- }, []);
+ }, [props.connection]);
let loadReplies = () => {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
@@ -54,7 +58,7 @@ export default function Thread(props) {
});
}
let onReply = (json) => {
- const msg = JSON.parse(json);
+ const msg = JSON.parse(json.data);
if (msg.mid == message.mid) {
setReplies([...this.state.replies, msg]);
}