From 850b87c1ec0ac1abfc9a3ed5c566bbe98fba9e7c Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Thu, 10 Dec 2020 03:50:40 -0500 Subject: cache channels --- components/memberlist.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'components/memberlist.cpp') diff --git a/components/memberlist.cpp b/components/memberlist.cpp index 04bdf8a..cf5e504 100644 --- a/components/memberlist.cpp +++ b/components/memberlist.cpp @@ -75,8 +75,8 @@ void MemberList::SetActiveChannel(Snowflake id) { m_chan_id = id; m_guild_id = Snowflake::Invalid; if (m_chan_id.IsValid()) { - auto *chan = Abaddon::Get().GetDiscordClient().GetChannel(id); - if (chan != nullptr) m_guild_id = chan->GuildID; + const auto chan = Abaddon::Get().GetDiscordClient().GetChannel(id); + if (chan.has_value()) m_guild_id = *chan->GuildID; } } @@ -99,11 +99,11 @@ void MemberList::UpdateMemberListInternal() { if (!m_chan_id.IsValid()) return; auto &discord = Abaddon::Get().GetDiscordClient(); - auto *chan = discord.GetChannel(m_chan_id); - if (chan == nullptr) return; + const auto chan = discord.GetChannel(m_chan_id); + if (!chan.has_value()) return; std::unordered_set ids; if (chan->Type == ChannelType::DM || chan->Type == ChannelType::GROUP_DM) { - for (const auto &user : chan->Recipients) + for (const auto &user : *chan->Recipients) ids.insert(user.ID); ids.insert(discord.GetUserData().ID); } else { -- cgit v1.2.3