From e523687328d7ac1851e78d719684069e8750ea2e Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 9 Dec 2020 13:08:36 +0400 Subject: [PATCH] Show bar waves from any member-s level. --- Telegram/SourceFiles/apiwrap.cpp | 7 +++--- Telegram/SourceFiles/calls/calls_top_bar.cpp | 22 ++++++++++++------- Telegram/SourceFiles/calls/calls_top_bar.h | 2 ++ .../SourceFiles/settings/settings_codes.cpp | 4 ++-- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index 29a91fb31a..4dc9a726c7 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -3981,6 +3981,7 @@ void ApiWrap::forwardMessages( ++shared->requestsLeft; } const auto requestType = Data::Histories::RequestType::Send; + const auto idsCopy = localIds; histories.sendRequest(history, requestType, [=](Fn finish) { history->sendRequestId = request(MTPmessages_ForwardMessages( MTP_flags(sendFlags), @@ -3995,9 +3996,9 @@ void ApiWrap::forwardMessages( shared->callback(); } finish(); - }).fail([=, ids = localIds](const RPCError &error) { - if (ids) { - for (const auto &[randomId, itemId] : *ids) { + }).fail([=](const RPCError &error) { + if (idsCopy) { + for (const auto &[randomId, itemId] : *idsCopy) { sendMessageFail(error, peer, randomId, itemId); } } else { diff --git a/Telegram/SourceFiles/calls/calls_top_bar.cpp b/Telegram/SourceFiles/calls/calls_top_bar.cpp index ab91675552..30ba5d18fa 100644 --- a/Telegram/SourceFiles/calls/calls_top_bar.cpp +++ b/Telegram/SourceFiles/calls/calls_top_bar.cpp @@ -43,6 +43,7 @@ constexpr auto kMinorBlobAlpha = 76. / 255.; constexpr auto kBlobLevelDuration1 = 250; constexpr auto kBlobLevelDuration2 = 120; +constexpr auto kBlobUpdateInterval = crl::time(100); auto LinearBlobs() -> std::array { return { { @@ -231,7 +232,9 @@ TopBar::TopBar( kBlobLevelDuration1, kBlobLevelDuration2, 1.)) -, _gradients(Colors(), QPointF(), QPointF()) { +, _blobsLevelTimer([=] { _blobsLastLevel = 0.; }) +, _gradients(Colors(), QPointF(), QPointF()) +, _updateDurationTimer([=] { updateDurationText(); }) { initControls(); resize(width(), st::callBarHeight); } @@ -346,7 +349,6 @@ void TopBar::initControls() { BoxContext::MainWindow)); } }); - _updateDurationTimer.setCallback([this] { updateDurationText(); }); updateDurationText(); initBlobs(); @@ -394,7 +396,7 @@ void TopBar::initBlobs() { return false; }) | rpl::distinct_until_changed() ) | rpl::map([](bool animDisabled, bool hide, bool isBadState) { - return isBadState || !(!animDisabled && !hide); + return isBadState || animDisabled || hide; }); std::move( @@ -407,6 +409,12 @@ void TopBar::initBlobs() { if (!hide && !_blobsAnimation.animating()) { _blobsAnimation.start(); } + if (hide) { + _blobsLevelTimer.cancel(); + } else { + _blobsLastLevel = 0.; + _blobsLevelTimer.callEach(kBlobUpdateInterval); + } const auto from = hide ? 0. : 1.; const auto to = hide ? 1. : 0.; @@ -465,12 +473,10 @@ void TopBar::initBlobs() { _groupCall->levelUpdates( ) | rpl::filter([=](const LevelUpdate &update) { - return update.self; + return !*hideLastTime && (update.value > _blobsLastLevel); }) | rpl::start_with_next([=](const LevelUpdate &update) { - if (*hideLastTime) { - return; - } - _blobsPaint->setLevel(update.value); + _blobsLastLevel = update.value; + _blobsPaint->setLevel(_blobsLastLevel); }, _blobs->lifetime()); _blobs->setAttribute(Qt::WA_TransparentForMouseEvents); diff --git a/Telegram/SourceFiles/calls/calls_top_bar.h b/Telegram/SourceFiles/calls/calls_top_bar.h index ab5f9cc330..e9ea275131 100644 --- a/Telegram/SourceFiles/calls/calls_top_bar.h +++ b/Telegram/SourceFiles/calls/calls_top_bar.h @@ -80,6 +80,8 @@ private: object_ptr _hangup; base::unique_qptr _blobs; std::unique_ptr _blobsPaint; + float _blobsLastLevel = 0.; + base::Timer _blobsLevelTimer; QBrush _groupBrush; anim::linear_gradients _gradients; diff --git a/Telegram/SourceFiles/settings/settings_codes.cpp b/Telegram/SourceFiles/settings/settings_codes.cpp index a83e690cef..ef99f5c1f9 100644 --- a/Telegram/SourceFiles/settings/settings_codes.cpp +++ b/Telegram/SourceFiles/settings/settings_codes.cpp @@ -108,8 +108,8 @@ auto GenerateCodes() { if (const auto strong = weak.get()) { loadFor(strong); } else { - for (const auto &[index, account] : Core::App().domain().accounts()) { - loadFor(account.get()); + for (const auto &pair : Core::App().domain().accounts()) { + loadFor(pair.account.get()); } } }