A platform for community discussion. Free, open, simple.
FIX: prevents chat to enter in endless loop when getting 404 (#18867)
Joffrey JAFFEUX49a0129b0d63
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-live-pane.js b/plugins/chat/assets/javascripts/discourse/components/chat-live-pane.jsindex e7ed4f500aa..e4200f06c92 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat-live-pane.js+++ b/plugins/chat/assets/javascripts/discourse/components/chat-live-pane.js@@ -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();});});},diff --git a/plugins/chat/test/javascripts/acceptance/chat-live-pane-test.js b/plugins/chat/test/javascripts/acceptance/chat-live-pane-test.jsindex 1ac586ff650..311012f0091 100644--- a/plugins/chat/test/javascripts/acceptance/chat-live-pane-test.js+++ b/plugins/chat/test/javascripts/acceptance/chat-live-pane-test.js@@ -252,6 +252,10 @@ acceptance(server.get("/chat/chat_channels/:chatChannelId", () =>helper.response({ id: 1, title: "something" }));++ server.get("/chat/lookup/:messageId.json", () => {+ return helper.response(404);+ });});test("Handles 404 errors by displaying an alert", async function (assert) {@@ -260,6 +264,13 @@ acceptance(assert.ok(exists(".dialog-content"), "it displays a 404 error");await click(".dialog-footer .btn-primary");});++ test("Handles 404 errors with unexisting messageId", async function (assert) {+ await visit("/chat/channel/1/cat?messageId=2");++ assert.ok(exists(".dialog-content"), "it displays a 404 error");+ await click(".dialog-footer .btn-primary");+ });});