FIX: Serialize thread membership for user (#21743)

This commit follows up b6c5a2da08c08b4df45c0885ec2757a117d83dea
by serializing the user's thread memberships in these cases:

1. When we do the initial channel fetch with messages, we get
   all threads and all the user's thread memberships for those
   messages.
2. When the thread list is fetched, we get all the user's memberships
   in that list.
3. When the single thread is fetched, either from opening it from
   the list, an OM indicator, or just from doing .find() on the
   manager when a new MessageBus message comes in

This will let us track the lastReadMessageId on the client, and
will also let us fix an issue where the unread indicator in the
channel header was incrementing for every thread that got a
new message, regardless of whether the user was a member.
This commit is contained in:
Martin Brennan
2023-05-25 12:54:50 +02:00
committed by GitHub
parent 0733dda1cb
commit c3779a371f
17 changed files with 161 additions and 29 deletions

View File

@ -54,5 +54,14 @@ describe "Thread tracking state | full page", type: :system, js: true do
expect(channel_page).to have_unread_thread_indicator(count: 1)
expect(thread_list_page).to have_unread_item(thread.id)
end
it "does not change the unread indicator for the header icon when the user is not a member of the thread" do
thread.remove(current_user)
chat_page.visit_channel(channel)
channel_page.open_thread_list
Fabricate(:chat_message, chat_channel: channel, thread: thread)
expect(channel_page).to have_no_unread_thread_indicator
expect(thread_list_page).to have_no_unread_item(thread.id)
end
end
end