add prefetch (default off)

This commit is contained in:
ouwou
2020-12-18 01:13:31 -05:00
parent 776c350eb6
commit 3916a50bf9
7 changed files with 50 additions and 2 deletions

View File

@@ -37,6 +37,17 @@ Abaddon::Abaddon()
m_discord.signal_guild_update().connect(sigc::mem_fun(*this, &Abaddon::DiscordOnGuildUpdate));
m_discord.signal_reaction_add().connect(sigc::mem_fun(*this, &Abaddon::DiscordOnReactionAdd));
m_discord.signal_reaction_remove().connect(sigc::mem_fun(*this, &Abaddon::DiscordOnReactionRemove));
if (m_settings.GetPrefetch())
m_discord.signal_message_create().connect([this](Snowflake id) {
const auto msg = m_discord.GetMessage(id);
const auto author = m_discord.GetUser(msg->Author.ID);
if (author.has_value() && author->HasAvatar())
m_img_mgr.Prefetch(author->GetAvatarURL());
for (const auto &attachment : msg->Attachments) {
if (IsURLViewableImage(attachment.ProxyURL))
m_img_mgr.Prefetch(attachment.ProxyURL);
}
});
}
Abaddon::~Abaddon() {