A platform for community discussion. Free, open, simple.
FIX: Ensure chat service has loaded channel before rendering channel (#35433)
Alan Guo Xiang Tan2baabe5ce6ac
diff --git a/plugins/chat/assets/javascripts/discourse/routes/chat-channel-decorator.js b/plugins/chat/assets/javascripts/discourse/routes/chat-channel-decorator.jsindex 3afde6f606d..19eeea39487 100644--- a/plugins/chat/assets/javascripts/discourse/routes/chat-channel-decorator.js+++ b/plugins/chat/assets/javascripts/discourse/routes/chat-channel-decorator.js@@ -7,6 +7,7 @@ export default function withChatChannel(extendedClass) {@service router;async model(params) {+ await this.chat.loadChannels();return this.chatChannelsManager.find(params.channelId);}diff --git a/plugins/chat/assets/javascripts/discourse/services/chat.js b/plugins/chat/assets/javascripts/discourse/services/chat.jsindex e7c82a41136..f70676b84f5 100644--- a/plugins/chat/assets/javascripts/discourse/services/chat.js+++ b/plugins/chat/assets/javascripts/discourse/services/chat.js@@ -192,17 +192,17 @@ export default class Chat extends Service {return;}- if (this.loadingChannels) {- return this.loadingChannels;+ if (!this.loadingChannels) {+ this.loadingChannels = new Promise((resolve) => {+ this.chatApi.listCurrentUserChannels().then((result) => {+ this.setupWithPreloadedChannels(result);+ this.chatStateManager.hasPreloadedChannels = true;+ resolve();+ });+ });}- this.loadingChannels = new Promise((resolve) => {- this.chatApi.listCurrentUserChannels().then((result) => {- this.setupWithPreloadedChannels(result);- this.chatStateManager.hasPreloadedChannels = true;- resolve();- });- });+ return this.loadingChannels;} catch (e) {popupAjaxError(e);}