mirror of
https://github.com/discourse/discourse.git
synced 2025-02-17 00:22:45 +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,
|
:chatable_url,
|
||||||
:description,
|
:description,
|
||||||
:title,
|
:title,
|
||||||
|
:unicode_title,
|
||||||
:slug,
|
:slug,
|
||||||
:status,
|
:status,
|
||||||
:archive_failed,
|
:archive_failed,
|
||||||
|
@ -53,6 +54,10 @@ module Chat
|
||||||
object.name || object.title(scope.user)
|
object.name || object.title(scope.user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def unicode_title
|
||||||
|
Emoji.gsub_emoji_to_unicode(title)
|
||||||
|
end
|
||||||
|
|
||||||
def chatable
|
def chatable
|
||||||
case object.chatable_type
|
case object.chatable_type
|
||||||
when "Category"
|
when "Category"
|
||||||
|
|
|
@ -87,6 +87,7 @@ export default class ChatChannel {
|
||||||
this.membershipsCount = args.memberships_count;
|
this.membershipsCount = args.memberships_count;
|
||||||
this.slug = args.slug;
|
this.slug = args.slug;
|
||||||
this.title = args.title;
|
this.title = args.title;
|
||||||
|
this.unicodeTitle = args.unicode_title;
|
||||||
this.status = args.status;
|
this.status = args.status;
|
||||||
this.description = args.description;
|
this.description = args.description;
|
||||||
this.threadingEnabled = args.threading_enabled;
|
this.threadingEnabled = args.threading_enabled;
|
||||||
|
|
|
@ -15,10 +15,12 @@ export default function withChatChannel(extendedClass) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const title = this.currentModel.unicodeTitle || this.currentModel.title;
|
||||||
|
|
||||||
if (this.currentModel.isDirectMessageChannel) {
|
if (this.currentModel.isDirectMessageChannel) {
|
||||||
return `${this.currentModel.title}`;
|
return `${title}`;
|
||||||
} else {
|
} else {
|
||||||
return `#${this.currentModel.title}`;
|
return `#${title}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,4 +113,10 @@ describe Chat::ChannelSerializer do
|
||||||
end
|
end
|
||||||
end
|
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
|
end
|
||||||
|
|
|
@ -419,4 +419,11 @@ RSpec.describe "Chat channel", type: :system do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user