From 6f1bd0014cad37f2f0b43a9b83733d9f65a91406 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Tue, 13 Jun 2023 21:28:18 -0400 Subject: refactor, update user mention handling --- src/components/chatmessage.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/components/chatmessage.cpp') diff --git a/src/components/chatmessage.cpp b/src/components/chatmessage.cpp index 4b2e748..2f3a86d 100644 --- a/src/components/chatmessage.cpp +++ b/src/components/chatmessage.cpp @@ -234,23 +234,23 @@ void ChatMessageItemContainer::UpdateTextComponent(Gtk::TextView *tv) { } break; case MessageType::CHANNEL_NAME_CHANGE: { const auto author = Abaddon::Get().GetDiscordClient().GetUser(data->Author.ID); - b->insert_markup(s, "" + author->GetEscapedBoldName() + " changed the name to " + Glib::Markup::escape_text(data->Content) + ""); + b->insert_markup(s, "" + author->GetDisplayNameEscapedBold() + " changed the name to " + Glib::Markup::escape_text(data->Content) + ""); } break; case MessageType::CHANNEL_ICON_CHANGE: { const auto author = Abaddon::Get().GetDiscordClient().GetUser(data->Author.ID); - b->insert_markup(s, "" + author->GetEscapedBoldName() + " changed the channel icon"); + b->insert_markup(s, "" + author->GetDisplayNameEscapedBold() + " changed the channel icon"); } break; case MessageType::USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1: case MessageType::USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2: case MessageType::USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3: { const auto author = Abaddon::Get().GetDiscordClient().GetUser(data->Author.ID); const auto guild = Abaddon::Get().GetDiscordClient().GetGuild(*data->GuildID); - b->insert_markup(s, "" + author->GetEscapedBoldName() + " just boosted the server " + Glib::Markup::escape_text(data->Content) + " times! " + + b->insert_markup(s, "" + author->GetDisplayNameEscapedBold() + " just boosted the server " + Glib::Markup::escape_text(data->Content) + " times! " + Glib::Markup::escape_text(guild->Name) + " has achieved Level " + std::to_string(static_cast(data->Type) - 8) + "!"); // oo cheeky me !!! } break; case MessageType::CHANNEL_FOLLOW_ADD: { const auto author = Abaddon::Get().GetDiscordClient().GetUser(data->Author.ID); - b->insert_markup(s, "" + author->GetEscapedBoldName() + " has added " + Glib::Markup::escape_text(data->Content) + " to this channel. Its most important updates will show up here."); + b->insert_markup(s, "" + author->GetDisplayNameEscapedBold() + " has added " + Glib::Markup::escape_text(data->Content) + " to this channel. Its most important updates will show up here."); } break; case MessageType::CALL: { b->insert_markup(s, "[started a call]"); @@ -270,13 +270,13 @@ void ChatMessageItemContainer::UpdateTextComponent(Gtk::TextView *tv) { case MessageType::THREAD_CREATED: { const auto author = Abaddon::Get().GetDiscordClient().GetUser(data->Author.ID); if (data->MessageReference.has_value() && data->MessageReference->ChannelID.has_value()) { - auto iter = b->insert_markup(s, "" + author->GetEscapedBoldName() + " started a thread: "); + auto iter = b->insert_markup(s, "" + author->GetDisplayNameEscapedBold() + " started a thread: "); auto tag = b->create_tag(); tag->property_weight() = Pango::WEIGHT_BOLD; m_channel_tagmap[tag] = *data->MessageReference->ChannelID; b->insert_with_tag(iter, data->Content, tag); } else { - b->insert_markup(s, "" + author->GetEscapedBoldName() + " started a thread: " + Glib::Markup::escape_text(data->Content) + ""); + b->insert_markup(s, "" + author->GetDisplayNameEscapedBold() + " started a thread: " + Glib::Markup::escape_text(data->Content) + ""); } } break; default: break; @@ -656,7 +656,7 @@ Gtk::Widget *ChatMessageItemContainer::CreateReplyComponent(const Message &data) if (role.has_value()) { const auto author = discord.GetUser(author_id); if (author.has_value()) { - return "Color) + "\">" + author->GetEscapedString() + ""; + return "Color) + "\">" + author->GetUsernameEscaped() + ""; } } } @@ -664,7 +664,7 @@ Gtk::Widget *ChatMessageItemContainer::CreateReplyComponent(const Message &data) const auto author = discord.GetUser(author_id); if (author.has_value()) { - return author->GetEscapedBoldString(); + return author->GetUsernameEscapedBold(); } return "Unknown User"; @@ -685,7 +685,7 @@ Gtk::Widget *ChatMessageItemContainer::CreateReplyComponent(const Message &data) Glib::Markup::escape_text(data.Interaction->Name) + ""); } else if (const auto user = discord.GetUser(data.Interaction->User.ID); user.has_value()) { - lbl->set_markup(user->GetEscapedBoldString()); + lbl->set_markup(user->GetUsernameEscapedBold()); } else { lbl->set_markup("Unknown User"); } @@ -1043,7 +1043,7 @@ void ChatMessageHeader::UpdateName() { else m_author.set_markup("" + name + ""); } else - m_author.set_markup("" + user->GetEscapedName() + ""); + m_author.set_markup("" + user->GetDisplayNameEscaped() + ""); } std::vector ChatMessageHeader::GetChildContent() { @@ -1069,7 +1069,7 @@ Glib::ustring ChatMessageHeader::GetEscapedDisplayName(const UserData &user, con if (member.has_value() && !member->Nickname.empty()) return Glib::Markup::escape_text(member->Nickname); else - return Glib::Markup::escape_text(user.GetEscapedName()); + return Glib::Markup::escape_text(user.GetDisplayNameEscaped()); } bool ChatMessageHeader::on_author_button_press(GdkEventButton *ev) { -- cgit v1.2.3