summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2023-06-14 01:56:46 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2023-06-14 01:56:46 -0400
commit878616e2efaa9a4fa1fa6b5e7dd376eb0dd1c79a (patch)
treefd91c196256096b985eb81b12260fd4039849d1d
parent5d9f7832d7ce73db75a58db0a3b798f24d147578 (diff)
downloadabaddon-portaudio-878616e2efaa9a4fa1fa6b5e7dd376eb0dd1c79a.tar.gz
abaddon-portaudio-878616e2efaa9a4fa1fa6b5e7dd376eb0dd1c79a.zip
use display name in typing indicator
-rw-r--r--src/components/chatinputindicator.cpp14
-rw-r--r--src/components/chatinputindicator.hpp1
-rw-r--r--src/discord/user.cpp7
-rw-r--r--src/discord/user.hpp1
4 files changed, 19 insertions, 4 deletions
diff --git a/src/components/chatinputindicator.cpp b/src/components/chatinputindicator.cpp
index 13315c6..0611e71 100644
--- a/src/components/chatinputindicator.cpp
+++ b/src/components/chatinputindicator.cpp
@@ -54,6 +54,12 @@ void ChatInputIndicator::AddUser(Snowflake channel_id, const UserData &user, int
void ChatInputIndicator::SetActiveChannel(Snowflake id) {
m_active_channel = id;
+ const auto channel = Abaddon::Get().GetDiscordClient().GetChannel(id);
+ if (channel.has_value()) {
+ m_active_guild = channel->GuildID;
+ } else {
+ m_active_guild = std::nullopt;
+ }
ComputeTypingString();
}
@@ -105,14 +111,14 @@ void ChatInputIndicator::ComputeTypingString() {
if (typers.empty()) {
SetTypingString("");
} else if (typers.size() == 1) {
- SetTypingString(typers[0].Username + " is typing...");
+ SetTypingString(typers[0].GetDisplayName(m_active_guild) + " is typing...");
} else if (typers.size() == 2) {
- SetTypingString(typers[0].Username + " and " + typers[1].Username + " are typing...");
+ SetTypingString(typers[0].GetDisplayName(m_active_guild) + " and " + typers[1].GetDisplayName(m_active_guild) + " are typing...");
} else if (typers.size() > 2 && typers.size() <= MaxUsersInIndicator) {
Glib::ustring str;
for (size_t i = 0; i < typers.size() - 1; i++)
- str += typers[i].Username + ", ";
- SetTypingString(str + "and " + typers[typers.size() - 1].Username + " are typing...");
+ str += typers[i].GetDisplayName(m_active_guild) + ", ";
+ SetTypingString(str + "and " + typers[typers.size() - 1].GetDisplayName(m_active_guild) + " are typing...");
} else { // size() > MaxUsersInIndicator
SetTypingString("Several people are typing...");
}
diff --git a/src/components/chatinputindicator.hpp b/src/components/chatinputindicator.hpp
index 40c966e..5688393 100644
--- a/src/components/chatinputindicator.hpp
+++ b/src/components/chatinputindicator.hpp
@@ -23,5 +23,6 @@ private:
Glib::ustring m_custom_markup;
Snowflake m_active_channel;
+ std::optional<Snowflake> m_active_guild;
std::unordered_map<Snowflake, std::unordered_map<Snowflake, sigc::connection>> m_typers; // channel id -> [user id -> connection]
};
diff --git a/src/discord/user.cpp b/src/discord/user.cpp
index 0f89fe2..f43284f 100644
--- a/src/discord/user.cpp
+++ b/src/discord/user.cpp
@@ -97,6 +97,13 @@ std::string UserData::GetDisplayName(Snowflake guild_id) const {
return GetDisplayName();
}
+std::string UserData::GetDisplayName(const std::optional<Snowflake> &guild_id) const {
+ if (guild_id.has_value()) {
+ return GetDisplayName(*guild_id);
+ }
+ return GetDisplayName();
+}
+
std::string UserData::GetDisplayNameEscaped() const {
return Glib::Markup::escape_text(GetDisplayName());
}
diff --git a/src/discord/user.hpp b/src/discord/user.hpp
index 29de62a..8b2a2c4 100644
--- a/src/discord/user.hpp
+++ b/src/discord/user.hpp
@@ -81,6 +81,7 @@ struct UserData {
[[nodiscard]] std::string GetMention() const;
[[nodiscard]] std::string GetDisplayName() const;
[[nodiscard]] std::string GetDisplayName(Snowflake guild_id) const;
+ [[nodiscard]] std::string GetDisplayName(const std::optional<Snowflake> &guild_id) const;
[[nodiscard]] std::string GetDisplayNameEscaped() const;
[[nodiscard]] std::string GetDisplayNameEscaped(Snowflake guild_id) const;
[[nodiscard]] std::string GetDisplayNameEscapedBold() const;