mirror of
https://github.com/discourse/discourse.git
synced 2025-01-30 04:31:43 +08:00
FIX: Sync channel tracking state properly on presence change (#21596)
Followup from9953a6edd9
, which broke an issue fixed ine8d6277062
. In the refactor we did not update the place where we resync channel tracking based on onPresenceChange to use the new tracking object we added to the serializer, and to directly update channel.tracking
This commit is contained in:
parent
0881186bfd
commit
009006893e
|
@ -108,6 +108,8 @@ export default class Chat extends Service {
|
|||
@bind
|
||||
onPresenceChangeCallback(present) {
|
||||
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
|
||||
|
@ -122,6 +124,13 @@ export default class Chat extends Service {
|
|||
.then((channel) => {
|
||||
if (channel) {
|
||||
channel.updateMembership(channelObject.current_user_membership);
|
||||
|
||||
const channelTrackingState =
|
||||
channels.tracking.channel_tracking[channel.id];
|
||||
channel.tracking.unreadCount =
|
||||
channelTrackingState.unread_count;
|
||||
channel.tracking.mentionCount =
|
||||
channelTrackingState.mention_count;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user