FEATURE: Thread indicator improvements and participants (#21909)

This commit adds the initial part of thread indicator improvements:

* Show the reply count, last reply date and excerpt,
and the participants of the thread's avatars and
count of additional participants
* Add a participants component for the thread that
can be reused for the list
* Add a query class to get the thread participants
* Live update the thread indicator more consistently
with the last reply and participant details
image image

In subsequent PRs we will cache the participants since
they do not change often, and improve the thread list
further with participants.

This commit also adds a showPresence boolean (default
true) to ChatUserAvatar, since we don't want to show the
online indicator for thread participants.

---------

Co-authored-by: chapoi <charlie@discourse.org>
This commit is contained in:
Martin Brennan
2023-06-15 10:49:27 +10:00
committed by GitHub
parent 897b6d86c7
commit f75ac9da30
58 changed files with 753 additions and 150 deletions

View File

@ -769,11 +769,6 @@ describe Chat::MessageCreator do
it "does not create a thread membership if one exists" do
Fabricate(:user_chat_thread_membership, user: user1, thread: existing_thread)
Fabricate(
:user_chat_thread_membership,
user: existing_thread.original_message_user,
thread: existing_thread,
)
expect {
described_class.create(
chat_channel: public_chat_channel,

View File

@ -610,6 +610,29 @@ describe Chat::MessageUpdater do
end
end
context "when the message is in a thread" do
fab!(:message) do
Fabricate(
:chat_message,
user: user1,
chat_channel: public_chat_channel,
thread: Fabricate(:chat_thread, channel: public_chat_channel),
)
end
it "publishes a MessageBus event to update the original message metadata" do
messages =
MessageBus.track_publish("/chat/#{public_chat_channel.id}") do
Chat::MessageUpdater.update(
guardian: guardian,
chat_message: message,
new_content: "some new updated content",
)
end
expect(messages.find { |m| m.data["type"] == "update_thread_original_message" }).to be_present
end
end
describe "watched words" do
fab!(:watched_word) { Fabricate(:watched_word) }