[FIX] Crash when open thread (#1395)
This commit is contained in:
parent
cfd63a6480
commit
2aaa27d49f
|
@ -39,15 +39,15 @@ class RightButtonsContainer extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
const { tmid, userId } = this.props;
|
const { tmid } = this.props;
|
||||||
if (tmid) {
|
if (tmid) {
|
||||||
const db = database.active;
|
const db = database.active;
|
||||||
const threadObservable = await db.collections.get('messages').findAndObserve(tmid);
|
try {
|
||||||
this.threadSubscription = threadObservable.subscribe((thread) => {
|
const threadRecord = await db.collections.get('messages').find(tmid);
|
||||||
this.setState({
|
this.observeThead(threadRecord);
|
||||||
isFollowingThread: thread.replies && !!thread.replies.find(t => t === userId)
|
} catch (e) {
|
||||||
});
|
console.log('Can\'t find message to observe.');
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,10 +57,16 @@ class RightButtonsContainer extends React.PureComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateThread = () => {
|
observeThead = (threadRecord) => {
|
||||||
|
const threadObservable = threadRecord.observe();
|
||||||
|
this.threadSubscription = threadObservable
|
||||||
|
.subscribe(thread => this.updateThread(thread));
|
||||||
|
}
|
||||||
|
|
||||||
|
updateThread = (thread) => {
|
||||||
const { userId } = this.props;
|
const { userId } = this.props;
|
||||||
this.setState({
|
this.setState({
|
||||||
isFollowingThread: this.thread.replies && !!this.thread.replies.find(t => t === userId)
|
isFollowingThread: thread.replies && !!thread.replies.find(t => t === userId)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue