From b550eb5ab2d81d6b1c05d3ba688178b4c23ab965 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 15 Dec 2020 14:49:08 +0400 Subject: [PATCH] Send speaking typings each 3 seconds. --- Telegram/SourceFiles/api/api_send_progress.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/api/api_send_progress.cpp b/Telegram/SourceFiles/api/api_send_progress.cpp index c21a1a516..c3436f7ab 100644 --- a/Telegram/SourceFiles/api/api_send_progress.cpp +++ b/Telegram/SourceFiles/api/api_send_progress.cpp @@ -19,7 +19,8 @@ namespace Api { namespace { constexpr auto kCancelTypingActionTimeout = crl::time(5000); -constexpr auto kSetMyActionForMs = 10 * crl::time(1000); +constexpr auto kSendMySpeakingInterval = 3 * crl::time(1000); +constexpr auto kSendMyTypingInterval = 5 * crl::time(1000); constexpr auto kSendTypingsToOfflineFor = TimeId(30); } // namespace @@ -82,12 +83,15 @@ bool SendProgressManager::updated(const Key &key, bool doing) { const auto now = crl::now(); const auto i = _updated.find(key); if (doing) { + const auto sendEach = (key.type == SendProgressType::Speaking) + ? kSendMySpeakingInterval + : kSendMyTypingInterval; if (i == end(_updated)) { - _updated.emplace(key, now + kSetMyActionForMs); - } else if (i->second > now + (kSetMyActionForMs / 2)) { + _updated.emplace(key, now + 2 * sendEach); + } else if (i->second > now + sendEach) { return false; } else { - i->second = now + kSetMyActionForMs; + i->second = now + 2 * sendEach; } } else { if (i == end(_updated)) {