mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Send speaking typing actions.
This commit is contained in:
parent
3134d68971
commit
624ee3bf60
7 changed files with 30 additions and 9 deletions
|
@ -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();
|
||||
}
|
||||
}();
|
||||
|
|
|
@ -31,6 +31,7 @@ enum class SendProgressType {
|
|||
ChooseLocation,
|
||||
ChooseContact,
|
||||
PlayGame,
|
||||
Speaking,
|
||||
};
|
||||
|
||||
struct SendProgress {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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*> _delegate;
|
||||
const not_null<ChannelData*> _channel;
|
||||
const not_null<History*> _history;
|
||||
MTP::Sender _api;
|
||||
rpl::variable<State> _state = State::Creating;
|
||||
bool _instanceConnected = false;
|
||||
|
@ -154,6 +157,8 @@ private:
|
|||
base::Timer _lastSpokeCheckTimer;
|
||||
base::Timer _checkJoinedTimer;
|
||||
|
||||
crl::time _lastSendProgressUpdate = 0;
|
||||
|
||||
rpl::lifetime _lifetime;
|
||||
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 &) {
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 84b3ac9b58626f29952b8a0589e950893bfc0577
|
||||
Subproject commit c4df097339aa7edf1d7aadde4df4a954971a3afb
|
Loading…
Add table
Reference in a new issue