diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2022-07-25 01:10:31 -0400 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2022-07-25 01:10:31 -0400 |
commit | 3610a2508b916af419051f557630135427185d4a (patch) | |
tree | d77e0a32ea6d943e6f75f313fc7ddd36cdd24152 | |
parent | 8396d07d9e7c8a3b7d7942694bd82c433eda99b4 (diff) | |
download | abaddon-portaudio-3610a2508b916af419051f557630135427185d4a.tar.gz abaddon-portaudio-3610a2508b916af419051f557630135427185d4a.zip |
limit how often progress bar can update
-rw-r--r-- | src/discord/discord.cpp | 3 | ||||
-rw-r--r-- | src/discord/discord.hpp | 2 |
2 files changed, 5 insertions, 0 deletions
diff --git a/src/discord/discord.cpp b/src/discord/discord.cpp index 21c0b87..5f49805 100644 --- a/src/discord/discord.cpp +++ b/src/discord/discord.cpp @@ -476,7 +476,10 @@ void DiscordClient::SendChatMessageAttachments(const ChatSubmitParams ¶ms, c obj.MessageReference.emplace().MessageID = params.InReplyToID; auto req = m_http.CreateRequest(http::REQUEST_POST, "/channels/" + std::to_string(params.ChannelID) + "/messages"); + m_progress_cb_timer.start(); req.set_progress_callback([this, nonce](curl_off_t ultotal, curl_off_t ulnow) { + if (m_progress_cb_timer.elapsed() < 0.0417) return; // try to prevent it from blocking ui + m_progress_cb_timer.start(); m_generic_mutex.lock(); m_generic_queue.push([this, nonce, ultotal, ulnow] { m_signal_message_progress.emit( diff --git a/src/discord/discord.hpp b/src/discord/discord.hpp index 1797150..718cb83 100644 --- a/src/discord/discord.hpp +++ b/src/discord/discord.hpp @@ -345,6 +345,8 @@ private: Glib::Dispatcher m_generic_dispatch; std::queue<std::function<void()>> m_generic_queue; + Glib::Timer m_progress_cb_timer; + std::set<Snowflake> m_channels_pinned_requested; std::set<Snowflake> m_channels_lazy_loaded; |