From 7db2675087a563ec82574937759137fa2e57298c Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Sun, 20 Jun 2021 20:32:16 -0400 Subject: fetch pins from store if already requested --- discord/discord.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'discord/discord.cpp') diff --git a/discord/discord.cpp b/discord/discord.cpp index ab5ab9f..89107df 100644 --- a/discord/discord.cpp +++ b/discord/discord.cpp @@ -720,6 +720,13 @@ void DiscordClient::Unpin(Snowflake channel_id, Snowflake message_id, sigc::slot } void DiscordClient::FetchPinned(Snowflake id, sigc::slot, DiscordError code)> callback) { + // return from db if we know the pins have already been requested + if (m_channels_pinned_requested.find(id) != m_channels_pinned_requested.end()) { + callback(m_store.GetPinnedMessages(id), DiscordError::NONE); + return; + } + m_channels_pinned_requested.insert(id); + m_http.MakeGET("/channels/" + std::to_string(id) + "/pins", [this, callback](const http::response_type &response) { if (!CheckCode(response)) { callback({}, GetCodeFromResponse(response)); -- cgit v1.2.3