A platform for community discussion. Free, open, simple.
FIX: correctly set last message bus ids on resync (#21911)
Joffrey JAFFEUX95a51b7d8aae
diff --git a/plugins/chat/assets/javascripts/discourse/services/chat-subscriptions-manager.js b/plugins/chat/assets/javascripts/discourse/services/chat-subscriptions-manager.jsindex 5dd75258bf7..b0ed9f1b264 100644--- a/plugins/chat/assets/javascripts/discourse/services/chat-subscriptions-manager.js+++ b/plugins/chat/assets/javascripts/discourse/services/chat-subscriptions-manager.js@@ -54,15 +54,6 @@ export default class ChatSubscriptionsManager extends Service {this._channelSubscriptions.delete(channel.id);}- restartChannelsSubscriptions(messageBusIds) {- this.stopChannelsSubscriptions();- this.startChannelsSubscriptions(messageBusIds);-- (this.chatChannelsManager.channels || []).forEach((channel) => {- this.startChannelSubscription(channel);- });- }-startChannelsSubscriptions(messageBusIds) {this._startNewChannelSubscription(messageBusIds.new_channel);this._startChannelArchiveStatusSubscription(messageBusIds.archive_status);diff --git a/plugins/chat/assets/javascripts/discourse/services/chat.js b/plugins/chat/assets/javascripts/discourse/services/chat.jsindex dcf145aa837..fbe7e9008b2 100644--- a/plugins/chat/assets/javascripts/discourse/services/chat.js+++ b/plugins/chat/assets/javascripts/discourse/services/chat.js@@ -115,14 +115,10 @@ export default class Chat extends Service {if (present) {// NOTE: channels is more than a simple array, it also contains// tracking and membership data, see Chat::StructuredChannelSerializer- this.chatApi.listCurrentUserChannels().then((channels) => {- this.chatSubscriptionsManager.restartChannelsSubscriptions(- channels.meta.message_bus_last_ids- );-+ this.chatApi.listCurrentUserChannels().then((channelsView) => {[- ...channels.public_channels,- ...channels.direct_message_channels,+ ...channelsView.public_channels,+ ...channelsView.direct_message_channels,].forEach((channelObject) => {this.chatChannelsManager.find(channelObject.id, { fetchIfNotFound: false })@@ -135,10 +131,11 @@ export default class Chat extends Service {// endpoint that gives you all channel tracking state and the// thread tracking state for the current channel.if (channel) {+ channel.meta.message_bus_last_ids =+ channelObject.meta.message_bus_last_ids;channel.updateMembership(channelObject.current_user_membership);-const channelTrackingState =- channels.tracking.channel_tracking[channel.id];+ channelsView.tracking.channel_tracking[channel.id];channel.tracking.unreadCount =channelTrackingState.unread_count;channel.tracking.mentionCount =