mirror of
https://github.com/discourse/discourse.git
synced 2025-03-06 11:19:51 +00:00
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:
parent
6e5e696c0b
commit
49a0129b0d
@ -243,6 +243,12 @@ export default Component.extend({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.setMessageProps(messages, fetchingFromLastRead);
|
this.setMessageProps(messages, fetchingFromLastRead);
|
||||||
|
|
||||||
|
if (this.targetMessageId) {
|
||||||
|
this.highlightOrFetchMessage(this.targetMessageId);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.focusComposer();
|
||||||
})
|
})
|
||||||
.catch(this._handleErrors)
|
.catch(this._handleErrors)
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
@ -252,12 +258,6 @@ export default Component.extend({
|
|||||||
|
|
||||||
this.chat.set("messageId", null);
|
this.chat.set("messageId", null);
|
||||||
this.set("loading", false);
|
this.set("loading", false);
|
||||||
|
|
||||||
if (this.targetMessageId) {
|
|
||||||
this.highlightOrFetchMessage(this.targetMessageId);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.focusComposer();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -252,6 +252,10 @@ acceptance(
|
|||||||
server.get("/chat/chat_channels/:chatChannelId", () =>
|
server.get("/chat/chat_channels/:chatChannelId", () =>
|
||||||
helper.response({ id: 1, title: "something" })
|
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) {
|
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");
|
assert.ok(exists(".dialog-content"), "it displays a 404 error");
|
||||||
await click(".dialog-footer .btn-primary");
|
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");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user