From 3916a50bf9a7b49a77d7c76b1e41a7773a04f53f Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Fri, 18 Dec 2020 01:13:31 -0500 Subject: add prefetch (default off) --- abaddon.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'abaddon.cpp') diff --git a/abaddon.cpp b/abaddon.cpp index 06dfab8..2fd6d39 100644 --- a/abaddon.cpp +++ b/abaddon.cpp @@ -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() { -- cgit v1.2.3