mirror of
https://github.com/element-hq/element-web.git
synced 2024-12-17 00:41:44 +03:00
add unmounted guard
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
25bc9cfbe7
commit
7bf05b0715
1 changed files with 11 additions and 0 deletions
|
@ -51,6 +51,8 @@ export default class Reply extends React.Component {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.onQuoteClick = this.onQuoteClick.bind(this);
|
this.onQuoteClick = this.onQuoteClick.bind(this);
|
||||||
|
|
||||||
|
this.unmounted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
|
@ -58,11 +60,17 @@ export default class Reply extends React.Component {
|
||||||
this.initialize();
|
this.initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
this.unmounted = true;
|
||||||
|
}
|
||||||
|
|
||||||
async initialize() {
|
async initialize() {
|
||||||
const {parentEv} = this.props;
|
const {parentEv} = this.props;
|
||||||
const inReplyTo = Reply.getInReplyTo(parentEv);
|
const inReplyTo = Reply.getInReplyTo(parentEv);
|
||||||
|
|
||||||
const ev = await this.getEvent(this.room, inReplyTo['event_id']);
|
const ev = await this.getEvent(this.room, inReplyTo['event_id']);
|
||||||
|
if (this.unmounted) return;
|
||||||
|
|
||||||
if (ev) {
|
if (ev) {
|
||||||
this.setState({
|
this.setState({
|
||||||
events: [ev],
|
events: [ev],
|
||||||
|
@ -78,6 +86,7 @@ export default class Reply extends React.Component {
|
||||||
const inReplyTo = Reply.getInReplyTo(ev);
|
const inReplyTo = Reply.getInReplyTo(ev);
|
||||||
|
|
||||||
if (!inReplyTo) {
|
if (!inReplyTo) {
|
||||||
|
if (this.unmounted) return;
|
||||||
this.setState({
|
this.setState({
|
||||||
loading: false,
|
loading: false,
|
||||||
});
|
});
|
||||||
|
@ -85,6 +94,8 @@ export default class Reply extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadedEv = await this.getEvent(this.room, inReplyTo['event_id']);
|
const loadedEv = await this.getEvent(this.room, inReplyTo['event_id']);
|
||||||
|
if (this.unmounted) return;
|
||||||
|
|
||||||
if (loadedEv) {
|
if (loadedEv) {
|
||||||
this.setState({loadedEv});
|
this.setState({loadedEv});
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue