mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Send speaking typings each 3 seconds.
This commit is contained in:
parent
aa5e8422bf
commit
b550eb5ab2
1 changed files with 8 additions and 4 deletions
|
@ -19,7 +19,8 @@ namespace Api {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr auto kCancelTypingActionTimeout = crl::time(5000);
|
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);
|
constexpr auto kSendTypingsToOfflineFor = TimeId(30);
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -82,12 +83,15 @@ bool SendProgressManager::updated(const Key &key, bool doing) {
|
||||||
const auto now = crl::now();
|
const auto now = crl::now();
|
||||||
const auto i = _updated.find(key);
|
const auto i = _updated.find(key);
|
||||||
if (doing) {
|
if (doing) {
|
||||||
|
const auto sendEach = (key.type == SendProgressType::Speaking)
|
||||||
|
? kSendMySpeakingInterval
|
||||||
|
: kSendMyTypingInterval;
|
||||||
if (i == end(_updated)) {
|
if (i == end(_updated)) {
|
||||||
_updated.emplace(key, now + kSetMyActionForMs);
|
_updated.emplace(key, now + 2 * sendEach);
|
||||||
} else if (i->second > now + (kSetMyActionForMs / 2)) {
|
} else if (i->second > now + sendEach) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
i->second = now + kSetMyActionForMs;
|
i->second = now + 2 * sendEach;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (i == end(_updated)) {
|
if (i == end(_updated)) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue