Skip to content

A platform for community discussion. Free, open, simple.

FIX: Show replies count on thread indicator regardless of participants (#22459)

Martin Brennan9b14bf82dc96
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-message-thread-indicator.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-message-thread-indicator.hbs
index 12f5cbbabbc..8557405da6e 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-message-thread-indicator.hbs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-message-thread-indicator.hbs
@@ -24,6 +24,9 @@
{{format-date @message.thread.preview.lastReplyCreatedAt leaveAgo="true"}}
</span>
</div>
+ <div class="chat-message-thread-indicator__replies-count">
+ {{i18n "chat.thread.replies" [email protected]}}
+ </div>
<Chat::Thread::Participants @thread={{@message.thread}} />
<div class="chat-message-thread-indicator__last-reply-excerpt">
{{replace-emoji (html-safe @message.thread.preview.lastReplyExcerpt)}}
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/thread/participants.hbs b/plugins/chat/assets/javascripts/discourse/components/chat/thread/participants.hbs
index f1c08cca433..cca09b3f96e 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat/thread/participants.hbs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat/thread/participants.hbs
@@ -1,7 +1,4 @@
{{#if (gt @thread.preview.participantUsers.length 1)}}
- <div class="chat-message-thread-indicator__replies-count">
- {{i18n "chat.thread.replies" [email protected]}}
- </div>
<div class="chat-thread-participants">
<div class="chat-thread-participants__avatar-group">
{{#each @thread.preview.participantUsers as |user|}}
diff --git a/plugins/chat/spec/system/message_thread_indicator_spec.rb b/plugins/chat/spec/system/message_thread_indicator_spec.rb
index 3c41cabae09..556b2955955 100644
--- a/plugins/chat/spec/system/message_thread_indicator_spec.rb
+++ b/plugins/chat/spec/system/message_thread_indicator_spec.rb
@@ -74,6 +74,20 @@ describe "Thread indicator for chat messages", type: :system do
)
end
+ it "it shows the reply count but no participant avatars when there is only one participant" do
+ single_user_thread =
+ Fabricate(:chat_thread, channel: channel, original_message_user: current_user)
+ Fabricate(:chat_message, thread: single_user_thread, user: current_user)
+ Fabricate(:chat_message, thread: single_user_thread, user: current_user)
+ chat_page.visit_channel(channel)
+ expect(
+ channel_page.message_thread_indicator(single_user_thread.original_message),
+ ).to have_reply_count(2)
+ expect(
+ channel_page.message_thread_indicator(single_user_thread.original_message),
+ ).to have_no_participants
+ end
+
it "clicking a thread indicator opens the thread panel" do
chat_page.visit_channel(channel)
channel_page.message_thread_indicator(thread_1.original_message).click
@@ -116,7 +130,7 @@ describe "Thread indicator for chat messages", type: :system do
)
end
- it "shows participants of the thread" do
+ it "shows avatars for the participants of the thread" do
chat_page.visit_channel(channel)
expect(channel_page.message_thread_indicator(thread_1.original_message)).to have_participant(
current_user,
diff --git a/plugins/chat/spec/system/page_objects/chat/components/thread_indicator.rb b/plugins/chat/spec/system/page_objects/chat/components/thread_indicator.rb
index b894a21364b..f4c8ecf7246 100644
--- a/plugins/chat/spec/system/page_objects/chat/components/thread_indicator.rb
+++ b/plugins/chat/spec/system/page_objects/chat/components/thread_indicator.rb
@@ -37,6 +37,10 @@ module PageObjects
)
end
+ def has_no_participants?
+ find(@context).has_no_css?(".chat-thread-participants")
+ end
+
def excerpt
find(@context).find("#{SELECTOR}__last-reply-excerpt")
end