handle nickname in reply component
This commit is contained in:
@@ -656,7 +656,7 @@ Gtk::Widget *ChatMessageItemContainer::CreateReplyComponent(const Message &data)
|
|||||||
if (role.has_value()) {
|
if (role.has_value()) {
|
||||||
const auto author = discord.GetUser(author_id);
|
const auto author = discord.GetUser(author_id);
|
||||||
if (author.has_value()) {
|
if (author.has_value()) {
|
||||||
return "<b><span color=\"#" + IntToCSSColor(role->Color) + "\">" + author->GetDisplayNameEscaped() + "</span></b>";
|
return "<b><span color=\"#" + IntToCSSColor(role->Color) + "\">" + author->GetDisplayNameEscaped(guild_id) + "</span></b>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -664,7 +664,7 @@ Gtk::Widget *ChatMessageItemContainer::CreateReplyComponent(const Message &data)
|
|||||||
|
|
||||||
const auto author = discord.GetUser(author_id);
|
const auto author = discord.GetUser(author_id);
|
||||||
if (author.has_value()) {
|
if (author.has_value()) {
|
||||||
return author->GetDisplayNameEscapedBold();
|
return author->GetDisplayNameEscapedBold(guild_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return "<b>Unknown User</b>";
|
return "<b>Unknown User</b>";
|
||||||
|
@@ -89,14 +89,30 @@ std::string UserData::GetDisplayName() const {
|
|||||||
return Username;
|
return Username;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string UserData::GetDisplayName(Snowflake guild_id) const {
|
||||||
|
const auto member = Abaddon::Get().GetDiscordClient().GetMember(ID, guild_id);
|
||||||
|
if (member.has_value() && !member->Nickname.empty()) {
|
||||||
|
return member->Nickname;
|
||||||
|
}
|
||||||
|
return GetDisplayName();
|
||||||
|
}
|
||||||
|
|
||||||
std::string UserData::GetDisplayNameEscaped() const {
|
std::string UserData::GetDisplayNameEscaped() const {
|
||||||
return Glib::Markup::escape_text(GetDisplayName());
|
return Glib::Markup::escape_text(GetDisplayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string UserData::GetDisplayNameEscaped(Snowflake guild_id) const {
|
||||||
|
return Glib::Markup::escape_text(GetDisplayName(guild_id));
|
||||||
|
}
|
||||||
|
|
||||||
std::string UserData::GetDisplayNameEscapedBold() const {
|
std::string UserData::GetDisplayNameEscapedBold() const {
|
||||||
return "<b>" + Glib::Markup::escape_text(GetDisplayName()) + "</b>";
|
return "<b>" + Glib::Markup::escape_text(GetDisplayName()) + "</b>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string UserData::GetDisplayNameEscapedBold(Snowflake guild_id) const {
|
||||||
|
return "<b>" + Glib::Markup::escape_text(GetDisplayName(guild_id)) + "</b>";
|
||||||
|
}
|
||||||
|
|
||||||
std::string UserData::GetUsername() const {
|
std::string UserData::GetUsername() const {
|
||||||
if (IsPomelo()) {
|
if (IsPomelo()) {
|
||||||
return Username;
|
return Username;
|
||||||
|
@@ -80,8 +80,11 @@ struct UserData {
|
|||||||
[[nodiscard]] Snowflake GetHoistedRole(Snowflake guild_id, bool with_color = false) const;
|
[[nodiscard]] Snowflake GetHoistedRole(Snowflake guild_id, bool with_color = false) const;
|
||||||
[[nodiscard]] std::string GetMention() const;
|
[[nodiscard]] std::string GetMention() const;
|
||||||
[[nodiscard]] std::string GetDisplayName() const;
|
[[nodiscard]] std::string GetDisplayName() const;
|
||||||
|
[[nodiscard]] std::string GetDisplayName(Snowflake guild_id) const;
|
||||||
[[nodiscard]] std::string GetDisplayNameEscaped() const;
|
[[nodiscard]] std::string GetDisplayNameEscaped() const;
|
||||||
|
[[nodiscard]] std::string GetDisplayNameEscaped(Snowflake guild_id) const;
|
||||||
[[nodiscard]] std::string GetDisplayNameEscapedBold() const;
|
[[nodiscard]] std::string GetDisplayNameEscapedBold() const;
|
||||||
|
[[nodiscard]] std::string GetDisplayNameEscapedBold(Snowflake guild_id) const;
|
||||||
[[nodiscard]] std::string GetUsername() const;
|
[[nodiscard]] std::string GetUsername() const;
|
||||||
[[nodiscard]] std::string GetUsernameEscaped() const;
|
[[nodiscard]] std::string GetUsernameEscaped() const;
|
||||||
[[nodiscard]] std::string GetUsernameEscapedBold() const;
|
[[nodiscard]] std::string GetUsernameEscapedBold() const;
|
||||||
|
Reference in New Issue
Block a user