Send speaking typings each 3 seconds.

This commit is contained in:
John Preston 2020-12-15 14:49:08 +04:00
parent aa5e8422bf
commit b550eb5ab2
1 changed files with 8 additions and 4 deletions

View File

@ -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)) {