From c697e70892626ba64b4705c7f7f1816f17a1929a Mon Sep 17 00:00:00 2001 From: David Battersby Date: Tue, 10 Sep 2024 11:52:25 +0400 Subject: [PATCH] FIX: prevent chat channel not found ajax error (#28818) On occasion we get an error popup on desktop due to the channel not being found. This change means that we only check the cached channels in ChatChannelsManager for the matching channel id, but we skip doing manual lookup which results in ajax popup when it fails. --- .../discourse/services/chat-notification-manager.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/chat/assets/javascripts/discourse/services/chat-notification-manager.js b/plugins/chat/assets/javascripts/discourse/services/chat-notification-manager.js index 7594a2343f0..09ef8742a0a 100644 --- a/plugins/chat/assets/javascripts/discourse/services/chat-notification-manager.js +++ b/plugins/chat/assets/javascripts/discourse/services/chat-notification-manager.js @@ -148,7 +148,9 @@ export default class ChatNotificationManager extends Service { @action async fetchChannel(channelId) { - return await this.chatChannelsManager.find(channelId); + return await this.chatChannelsManager.find(channelId, { + fetchIfNotFound: false, + }); } @bind @@ -159,7 +161,10 @@ export default class ChatNotificationManager extends Service { if (this.site.desktopView) { const channel = await this.fetchChannel(data.channel_id); - data.isDirectMessageChannel = channel.isDirectMessageChannel ?? false; + + if (channel) { + data.isDirectMessageChannel = channel.isDirectMessageChannel ?? false; + } return onDesktopNotification( data,