FIX: prevents chat to enter in endless loop when getting 404 (#18867)

Doing DOM operations in finally would cause them to happen even when the request was a failure. Consequence of these DOM operations would be new request, which would also end up in a 404, and so on.

This commit simply moves the DOM operations in the then block where it should be safe to make.
This commit is contained in:
Joffrey JAFFEUX
2022-11-03 19:52:44 +01:00
committed by GitHub
parent 6e5e696c0b
commit 49a0129b0d
2 changed files with 17 additions and 6 deletions
@@ -243,6 +243,12 @@ export default Component.extend({
return;
}
this.setMessageProps(messages, fetchingFromLastRead);
if (this.targetMessageId) {
this.highlightOrFetchMessage(this.targetMessageId);
}
this.focusComposer();
})
.catch(this._handleErrors)
.finally(() => {
@@ -252,12 +258,6 @@ export default Component.extend({
this.chat.set("messageId", null);
this.set("loading", false);
if (this.targetMessageId) {
this.highlightOrFetchMessage(this.targetMessageId);
}
this.focusComposer();
});
});
},