2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Use new animations engine for typings.

This commit is contained in:
John Preston
2019-04-01 18:53:18 +04:00
parent 3971f27c66
commit cd3c1c6dc0
15 changed files with 301 additions and 233 deletions

View File

@@ -151,7 +151,9 @@ Session::Session(not_null<AuthSession*> session)
Local::cacheBigFilePath(),
Local::cacheBigFileSettings()))
, _selfDestructTimer([=] { checkSelfDestructItems(); })
, _a_sendActions(animation(this, &Session::step_typings))
, _sendActionsAnimation([=](crl::time now) {
return sendActionsAnimationCallback(now);
})
, _groups(this)
, _unmuteByFinishedTimer([=] { unmuteByFinished(); }) {
_cache->open(Local::cacheKey());
@@ -241,7 +243,8 @@ not_null<UserData*> Session::processUser(const MTPUser &data) {
return data.vid.v;
}));
auto minimal = false;
const MTPUserStatus *status = 0, emptyStatus = MTP_userStatusEmpty();
const MTPUserStatus *status = nullptr;
const MTPUserStatus emptyStatus = MTP_userStatusEmpty();
Notify::PeerUpdate update;
using UpdateFlag = Notify::PeerUpdate::Flag;
@@ -749,22 +752,20 @@ void Session::registerSendAction(
const auto i = _sendActions.find(history);
if (!_sendActions.contains(history)) {
_sendActions.emplace(history, crl::now());
_a_sendActions.start();
_sendActionsAnimation.start();
}
}
}
void Session::step_typings(crl::time ms, bool timer) {
bool Session::sendActionsAnimationCallback(crl::time now) {
for (auto i = begin(_sendActions); i != end(_sendActions);) {
if (i->first->updateSendActionNeedsAnimating(ms)) {
if (i->first->updateSendActionNeedsAnimating(now)) {
++i;
} else {
i = _sendActions.erase(i);
}
}
if (_sendActions.empty()) {
_a_sendActions.stop();
}
return !_sendActions.empty();
}
Storage::Cache::Database &Session::cache() {