FIX: Avoid transitioning when a chat thread component is destroyed (#22457)

Why this change?

Before this commit, there is a chance that we will transition the user
to a different route if the chat thread component has been destroyed
prior to the request for fetching messasges in a chat thread returning.

This commit makes it such that we simply ignore the request if the chat
thread component has been destroyed.

We believe this is the cause of the flaky system tests in plugins/chat/spec/system/navigation_spec.rb
which we've been seeing on CI.
This commit is contained in:
Alan Guo Xiang Tan 2023-07-06 10:53:28 +08:00 committed by GitHub
parent ff38bccb80
commit 4c810703c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -166,10 +166,11 @@ export default class ChatThreadPanel extends Component {
return this.chatApi
.channel(this.args.thread.channel.id, findArgs)
.then((result) => {
if (
this._selfDeleted ||
this.args.thread.channel.id !== result.meta.channel_id
) {
if (this._selfDeleted) {
return;
}
if (this.args.thread.channel.id !== result.meta.channel_id) {
if (this.chatHistory.previousRoute?.name === "chat.channel.index") {
this.router.transitionTo(
"chat.channel",