mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-13 20:18:50 +03:00
fix tab titles
This commit is contained in:
@@ -70,7 +70,7 @@ void ChannelTabSwitcherHandy::ReplaceActiveTab(Snowflake id) {
|
||||
const auto channel = discord.GetChannel(id);
|
||||
if (!channel.has_value()) return;
|
||||
|
||||
hdy_tab_page_set_title(page, ("#" + *channel->Name).c_str());
|
||||
hdy_tab_page_set_title(page, channel->GetDisplayName().c_str());
|
||||
|
||||
ClearPage(page);
|
||||
m_pages[id] = page;
|
||||
|
||||
@@ -92,6 +92,19 @@ std::string ChannelData::GetIconURL() const {
|
||||
return "https://cdn.discordapp.com/channel-icons/" + std::to_string(ID) + "/" + *Icon + ".png";
|
||||
}
|
||||
|
||||
std::string ChannelData::GetDisplayName() const {
|
||||
if (Name.has_value()) {
|
||||
return "#" + *Name;
|
||||
} else {
|
||||
const auto recipients = GetDMRecipients();
|
||||
if (Type == ChannelType::DM && !recipients.empty())
|
||||
return recipients[0].Username;
|
||||
else if (Type == ChannelType::GROUP_DM)
|
||||
return std::to_string(recipients.size()) + " members";
|
||||
}
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
std::vector<Snowflake> ChannelData::GetChildIDs() const {
|
||||
return Abaddon::Get().GetDiscordClient().GetChildChannelIDs(ID);
|
||||
}
|
||||
|
||||
@@ -102,6 +102,7 @@ struct ChannelData {
|
||||
[[nodiscard]] bool IsText() const noexcept;
|
||||
[[nodiscard]] bool HasIcon() const noexcept;
|
||||
[[nodiscard]] std::string GetIconURL() const;
|
||||
[[nodiscard]] std::string GetDisplayName() const;
|
||||
[[nodiscard]] std::vector<Snowflake> GetChildIDs() const;
|
||||
[[nodiscard]] std::optional<PermissionOverwrite> GetOverwrite(Snowflake id) const;
|
||||
[[nodiscard]] std::vector<UserData> GetDMRecipients() const;
|
||||
|
||||
Reference in New Issue
Block a user