UX: remove alias from chat direct message channel titles (#28958)

Makes usernames in Chat Direct Message channels consistent with other areas of the app by removing the alias.
This commit is contained in:
David Battersby 2024-09-18 22:18:46 +04:00 committed by GitHub
parent 05b8ff436c
commit 4bfe78d1e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 11 deletions

View File

@ -50,9 +50,9 @@ module Chat
username: username:
( (
if prefers_name if prefers_name
acting_user.name.presence || "@#{acting_user.username}" acting_user.name.presence || acting_user.username
else else
"@#{acting_user.username}" acting_user.username
end end
), ),
) )
@ -65,9 +65,9 @@ module Chat
formatted_names = formatted_names =
( (
if prefers_name if prefers_name
users.map { |u| u.name.presence || "@#{u.username}" }.sort_by { |name| name[1..-1] } users.map { |u| u.name.presence || u.username }.sort_by { |name| name[1..-1] }
else else
users.sort_by(&:username).map { |u| "@#{u.username}" } users.map(&:username).sort
end end
) )

View File

@ -19,7 +19,7 @@ describe Chat::DirectMessage do
I18n.t( I18n.t(
"chat.channel.dm_title.multi_user", "chat.channel.dm_title.multi_user",
comma_separated_usernames: comma_separated_usernames:
[user3, user2].map { |u| "@#{u.username}" }.join(I18n.t("word_connector.comma")), [user3, user2].map { |u| u.username }.join(I18n.t("word_connector.comma")),
), ),
) )
end end
@ -38,7 +38,7 @@ describe Chat::DirectMessage do
comma_separated_usernames: comma_separated_usernames:
users[1..6] users[1..6]
.sort_by(&:username) .sort_by(&:username)
.map { |u| "@#{u.username}" } .map { |u| u.username }
.join(I18n.t("word_connector.comma")), .join(I18n.t("word_connector.comma")),
count: 2, count: 2,
), ),
@ -49,7 +49,7 @@ describe Chat::DirectMessage do
direct_message = Fabricate(:direct_message, users: [user1, user2]) direct_message = Fabricate(:direct_message, users: [user1, user2])
expect(direct_message.chat_channel_title_for_user(chat_channel, user1)).to eq( expect(direct_message.chat_channel_title_for_user(chat_channel, user1)).to eq(
I18n.t("chat.channel.dm_title.single_user", username: "@#{user2.username}"), I18n.t("chat.channel.dm_title.single_user", username: user2.username),
) )
end end
@ -57,7 +57,7 @@ describe Chat::DirectMessage do
direct_message = Fabricate(:direct_message, users: [user1]) direct_message = Fabricate(:direct_message, users: [user1])
expect(direct_message.chat_channel_title_for_user(chat_channel, user1)).to eq( expect(direct_message.chat_channel_title_for_user(chat_channel, user1)).to eq(
I18n.t("chat.channel.dm_title.single_user", username: "@#{user1.username}"), I18n.t("chat.channel.dm_title.single_user", username: user1.username),
) )
end end
@ -68,7 +68,7 @@ describe Chat::DirectMessage do
direct_message.reload direct_message.reload
expect(direct_message.chat_channel_title_for_user(chat_channel, user1)).to eq( expect(direct_message.chat_channel_title_for_user(chat_channel, user1)).to eq(
"@#{I18n.t("chat.deleted_chat_username")}", I18n.t("chat.deleted_chat_username"),
) )
end end
end end
@ -112,7 +112,7 @@ describe Chat::DirectMessage do
expect(direct_message.chat_channel_title_for_user(chat_channel, user1)).to eq( expect(direct_message.chat_channel_title_for_user(chat_channel, user1)).to eq(
I18n.t( I18n.t(
"chat.channel.dm_title.multi_user", "chat.channel.dm_title.multi_user",
comma_separated_usernames: ["@#{user2.username}", new_user.name].join( comma_separated_usernames: [user2.username, new_user.name].join(
I18n.t("word_connector.comma"), I18n.t("word_connector.comma"),
), ),
), ),

View File

@ -182,7 +182,7 @@ RSpec.describe "Sidebar navigation menu", type: :system do
visit("/") visit("/")
expect(sidebar_page.dms_section.find(".channel-#{dm_channel_1.id}")["title"]).to eq( expect(sidebar_page.dms_section.find(".channel-#{dm_channel_1.id}")["title"]).to eq(
"Chat with @<script>alert('hello')</script>", "Chat with <script>alert('hello')</script>",
) )
end end
end end