diff --git a/Telegram/SourceFiles/api/api_send_progress.cpp b/Telegram/SourceFiles/api/api_send_progress.cpp index 6def1f9cd..c21a1a516 100644 --- a/Telegram/SourceFiles/api/api_send_progress.cpp +++ b/Telegram/SourceFiles/api/api_send_progress.cpp @@ -121,6 +121,7 @@ void SendProgressManager::send(const Key &key, int progress) { case Type::ChooseLocation: return MTP_sendMessageGeoLocationAction(); case Type::ChooseContact: return MTP_sendMessageChooseContactAction(); case Type::PlayGame: return MTP_sendMessageGamePlayAction(); + case Type::Speaking: return MTP_speakingInGroupCallAction(); default: return MTP_sendMessageTypingAction(); } }(); diff --git a/Telegram/SourceFiles/api/api_send_progress.h b/Telegram/SourceFiles/api/api_send_progress.h index 22bed6ac1..511e25cc1 100644 --- a/Telegram/SourceFiles/api/api_send_progress.h +++ b/Telegram/SourceFiles/api/api_send_progress.h @@ -31,6 +31,7 @@ enum class SendProgressType { ChooseLocation, ChooseContact, PlayGame, + Speaking, }; struct SendProgress { diff --git a/Telegram/SourceFiles/calls/calls_group_call.cpp b/Telegram/SourceFiles/calls/calls_group_call.cpp index 09ed5804e..d03bdda74 100644 --- a/Telegram/SourceFiles/calls/calls_group_call.cpp +++ b/Telegram/SourceFiles/calls/calls_group_call.cpp @@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "calls/calls_group_call.h" #include "main/main_session.h" +#include "api/api_send_progress.h" #include "apiwrap.h" #include "lang/lang_keys.h" #include "boxes/confirm_box.h" @@ -38,6 +39,7 @@ constexpr auto kMaxInvitePerSlice = 10; constexpr auto kCheckLastSpokeInterval = 3 * crl::time(1000); constexpr auto kSpeakLevelThreshold = 0.2; constexpr auto kCheckJoinedTimeout = 4 * crl::time(1000); +constexpr auto kUpdateSendActionEach = crl::time(500); } // namespace @@ -47,6 +49,7 @@ GroupCall::GroupCall( const MTPInputGroupCall &inputCall) : _delegate(delegate) , _channel(channel) +, _history(channel->owner().history(channel)) , _api(&_channel->session().mtp()) , _lastSpokeCheckTimer([=] { checkLastSpoke(); }) , _checkJoinedTimer([=] { checkJoined(); }) { @@ -154,9 +157,11 @@ void GroupCall::join(const MTPInputGroupCall &inputCall) { } void GroupCall::rejoin() { - Expects(_state.current() == State::Joining - || _state.current() == State::Joined - || _state.current() == State::Connecting); + if (state() != State::Joining + && state() != State::Joined + && state() != State::Connecting) { + return; + } _mySsrc = 0; setState(State::Joining); @@ -491,14 +496,23 @@ void GroupCall::handleLevelsUpdated( auto checkNow = false; const auto now = crl::now(); for (const auto &[source, level] : data) { + const auto self = (source == _mySsrc); _levelUpdates.fire(LevelUpdate{ .source = source, .value = level, - .self = (source == _mySsrc) + .self = self }); if (level <= kSpeakLevelThreshold) { continue; } + if (self + && (!_lastSendProgressUpdate + || _lastSendProgressUpdate + kUpdateSendActionEach < now)) { + _lastSendProgressUpdate = now; + _channel->session().sendProgressManager().update( + _history, + Api::SendProgressType::Speaking); + } check = true; const auto i = _lastSpoke.find(source); diff --git a/Telegram/SourceFiles/calls/calls_group_call.h b/Telegram/SourceFiles/calls/calls_group_call.h index db2a0aa62..b8c1f7988 100644 --- a/Telegram/SourceFiles/calls/calls_group_call.h +++ b/Telegram/SourceFiles/calls/calls_group_call.h @@ -13,6 +13,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mtproto/sender.h" #include "mtproto/mtproto_auth_key.h" +class History; + namespace tgcalls { class GroupInstanceImpl; } // namespace tgcalls @@ -135,6 +137,7 @@ private: const not_null _delegate; const not_null _channel; + const not_null _history; MTP::Sender _api; rpl::variable _state = State::Creating; bool _instanceConnected = false; @@ -154,6 +157,8 @@ private: base::Timer _lastSpokeCheckTimer; base::Timer _checkJoinedTimer; + crl::time _lastSendProgressUpdate = 0; + rpl::lifetime _lifetime; }; diff --git a/Telegram/SourceFiles/calls/calls_group_settings.cpp b/Telegram/SourceFiles/calls/calls_group_settings.cpp index 8f4ab9eaa..5a4246c16 100644 --- a/Telegram/SourceFiles/calls/calls_group_settings.cpp +++ b/Telegram/SourceFiles/calls/calls_group_settings.cpp @@ -115,7 +115,7 @@ void GroupCallSettingsBox( ), st::groupCallSettingsButton )->addClickHandler([=] { - box->getDelegate()->show(ChooseAudioInputBox(crl::guard(box, [=]( + box->getDelegate()->show(ChooseAudioOutputBox(crl::guard(box, [=]( const QString &id, const QString &name) { state->outputNameStream.fire_copy(name); diff --git a/Telegram/SourceFiles/history/view/history_view_send_action.cpp b/Telegram/SourceFiles/history/view/history_view_send_action.cpp index f62efa170..8719aacfb 100644 --- a/Telegram/SourceFiles/history/view/history_view_send_action.cpp +++ b/Telegram/SourceFiles/history/view/history_view_send_action.cpp @@ -51,9 +51,9 @@ bool SendActionPainter::updateNeedsAnimating( const auto now = crl::now(); const auto emplaceAction = [&]( - Type type, - crl::time duration, - int progress = 0) { + Type type, + crl::time duration, + int progress = 0) { _sendActions.emplace_or_assign(user, type, now + duration, progress); }; action.match([&](const MTPDsendMessageTypingAction &) { diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 84b3ac9b5..c4df09733 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 84b3ac9b58626f29952b8a0589e950893bfc0577 +Subproject commit c4df097339aa7edf1d7aadde4df4a954971a3afb