forked from OpenGamers/abaddon
support channel icons for dms
This commit is contained in:
@@ -752,7 +752,13 @@ void ChannelList::AddPrivateChannels() {
|
|||||||
else if (dm->Type == ChannelType::GROUP_DM)
|
else if (dm->Type == ChannelType::GROUP_DM)
|
||||||
row[m_columns.m_name] = std::to_string(recipients.size()) + " members";
|
row[m_columns.m_name] = std::to_string(recipients.size()) + " members";
|
||||||
|
|
||||||
if (top_recipient.has_value()) {
|
if (dm->HasIcon()) {
|
||||||
|
const auto cb = [this, iter](const Glib::RefPtr<Gdk::Pixbuf> &pb) {
|
||||||
|
if (iter)
|
||||||
|
(*iter)[m_columns.m_icon] = pb->scale_simple(DMIconSize, DMIconSize, Gdk::INTERP_BILINEAR);
|
||||||
|
};
|
||||||
|
img.LoadFromURL(dm->GetIconURL(), sigc::track_obj(cb, *this));
|
||||||
|
} else if (top_recipient.has_value()) {
|
||||||
const auto cb = [this, iter](const Glib::RefPtr<Gdk::Pixbuf> &pb) {
|
const auto cb = [this, iter](const Glib::RefPtr<Gdk::Pixbuf> &pb) {
|
||||||
if (iter)
|
if (iter)
|
||||||
(*iter)[m_columns.m_icon] = pb->scale_simple(DMIconSize, DMIconSize, Gdk::INTERP_BILINEAR);
|
(*iter)[m_columns.m_icon] = pb->scale_simple(DMIconSize, DMIconSize, Gdk::INTERP_BILINEAR);
|
||||||
|
|||||||
@@ -84,6 +84,14 @@ bool ChannelData::IsCategory() const noexcept {
|
|||||||
return Type == ChannelType::GUILD_CATEGORY;
|
return Type == ChannelType::GUILD_CATEGORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ChannelData::HasIcon() const noexcept {
|
||||||
|
return Icon.has_value();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string ChannelData::GetIconURL() const {
|
||||||
|
return "https://cdn.discordapp.com/channel-icons/" + std::to_string(ID) + "/" + *Icon + ".png";
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<Snowflake> ChannelData::GetChildIDs() const {
|
std::vector<Snowflake> ChannelData::GetChildIDs() const {
|
||||||
return Abaddon::Get().GetDiscordClient().GetChildChannelIDs(ID);
|
return Abaddon::Get().GetDiscordClient().GetChildChannelIDs(ID);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,6 +99,8 @@ struct ChannelData {
|
|||||||
bool IsThread() const noexcept;
|
bool IsThread() const noexcept;
|
||||||
bool IsJoinedThread() const;
|
bool IsJoinedThread() const;
|
||||||
bool IsCategory() const noexcept;
|
bool IsCategory() const noexcept;
|
||||||
|
bool HasIcon() const noexcept;
|
||||||
|
std::string GetIconURL() const;
|
||||||
std::vector<Snowflake> GetChildIDs() const;
|
std::vector<Snowflake> GetChildIDs() const;
|
||||||
std::optional<PermissionOverwrite> GetOverwrite(Snowflake id) const;
|
std::optional<PermissionOverwrite> GetOverwrite(Snowflake id) const;
|
||||||
std::vector<UserData> GetDMRecipients() const;
|
std::vector<UserData> GetDMRecipients() const;
|
||||||
|
|||||||
@@ -646,6 +646,7 @@ std::optional<ChannelData> Store::GetChannel(Snowflake id) const {
|
|||||||
s->Get(6, r.IsNSFW);
|
s->Get(6, r.IsNSFW);
|
||||||
s->Get(7, r.LastMessageID);
|
s->Get(7, r.LastMessageID);
|
||||||
s->Get(10, r.RateLimitPerUser);
|
s->Get(10, r.RateLimitPerUser);
|
||||||
|
s->Get(11, r.Icon);
|
||||||
s->Get(12, r.OwnerID);
|
s->Get(12, r.OwnerID);
|
||||||
s->Get(14, r.ParentID);
|
s->Get(14, r.ParentID);
|
||||||
if (!s->IsNull(16)) {
|
if (!s->IsNull(16)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user