fix double escaped username in message headers (#239, fixes #236)

This commit is contained in:
ouwou 2023-10-20 20:30:39 -04:00
parent 5e244e5cb8
commit 893c9b5241
2 changed files with 1 additions and 10 deletions

View File

@ -1057,10 +1057,9 @@ void ChatMessageHeader::UpdateName() {
const auto chan = discord.GetChannel(ChannelID);
bool is_guild = chan.has_value() && chan->GuildID.has_value();
if (is_guild) {
const auto member = discord.GetMember(UserID, *chan->GuildID);
const auto role_id = discord.GetMemberHoistedRole(*chan->GuildID, UserID, true);
const auto role = discord.GetRole(role_id);
const auto name = GetEscapedDisplayName(*user, member);
const auto name = user->GetDisplayNameEscaped(*chan->GuildID);
std::string md;
if (role.has_value())
@ -1090,13 +1089,6 @@ void ChatMessageHeader::AttachUserMenuHandler(Gtk::Widget &widget) {
});
}
Glib::ustring ChatMessageHeader::GetEscapedDisplayName(const UserData &user, const std::optional<GuildMember> &member) {
if (member.has_value() && !member->Nickname.empty())
return Glib::Markup::escape_text(member->Nickname);
else
return Glib::Markup::escape_text(user.GetDisplayNameEscaped());
}
bool ChatMessageHeader::on_author_button_press(GdkEventButton *ev) {
if (ev->button == GDK_BUTTON_PRIMARY && (ev->state & GDK_SHIFT_MASK)) {
m_signal_action_insert_mention.emit();

View File

@ -84,7 +84,6 @@ public:
protected:
void AttachUserMenuHandler(Gtk::Widget &widget);
static Glib::ustring GetEscapedDisplayName(const UserData &user, const std::optional<GuildMember> &member);
bool on_author_button_press(GdkEventButton *ev);