mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 06:28:57 +08:00
FIX: correctly render unicode in channel page title (#29653)
Before this fix we would render the emoji as text, eg: `🐱`
This commit is contained in:
parent
5a23a74bbc
commit
79254c59f9
|
@ -11,6 +11,7 @@ module Chat
|
|||
:chatable_url,
|
||||
:description,
|
||||
:title,
|
||||
:unicode_title,
|
||||
:slug,
|
||||
:status,
|
||||
:archive_failed,
|
||||
|
@ -53,6 +54,10 @@ module Chat
|
|||
object.name || object.title(scope.user)
|
||||
end
|
||||
|
||||
def unicode_title
|
||||
Emoji.gsub_emoji_to_unicode(title)
|
||||
end
|
||||
|
||||
def chatable
|
||||
case object.chatable_type
|
||||
when "Category"
|
||||
|
|
|
@ -87,6 +87,7 @@ export default class ChatChannel {
|
|||
this.membershipsCount = args.memberships_count;
|
||||
this.slug = args.slug;
|
||||
this.title = args.title;
|
||||
this.unicodeTitle = args.unicode_title;
|
||||
this.status = args.status;
|
||||
this.description = args.description;
|
||||
this.threadingEnabled = args.threading_enabled;
|
||||
|
|
|
@ -15,10 +15,12 @@ export default function withChatChannel(extendedClass) {
|
|||
return;
|
||||
}
|
||||
|
||||
const title = this.currentModel.unicodeTitle || this.currentModel.title;
|
||||
|
||||
if (this.currentModel.isDirectMessageChannel) {
|
||||
return `${this.currentModel.title}`;
|
||||
return `${title}`;
|
||||
} else {
|
||||
return `#${this.currentModel.title}`;
|
||||
return `#${title}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -113,4 +113,10 @@ describe Chat::ChannelSerializer do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
it "has a unicode_title" do
|
||||
chat_channel.update!(name: ":cat: Cats")
|
||||
|
||||
expect(serializer.as_json[:unicode_title]).to eq("🐱 Cats")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -419,4 +419,11 @@ RSpec.describe "Chat channel", type: :system do
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
it "renders emojis in page title" do
|
||||
channel_1.update!(name: ":dog: Dogs")
|
||||
chat_page.visit_channel(channel_1)
|
||||
|
||||
expect(page).to have_title("#🐶 Dogs - Chat - Discourse")
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user