mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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::ChooseLocation: return MTP_sendMessageGeoLocationAction();
|
||||||
case Type::ChooseContact: return MTP_sendMessageChooseContactAction();
|
case Type::ChooseContact: return MTP_sendMessageChooseContactAction();
|
||||||
case Type::PlayGame: return MTP_sendMessageGamePlayAction();
|
case Type::PlayGame: return MTP_sendMessageGamePlayAction();
|
||||||
|
case Type::Speaking: return MTP_speakingInGroupCallAction();
|
||||||
default: return MTP_sendMessageTypingAction();
|
default: return MTP_sendMessageTypingAction();
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
|
|
|
@ -31,6 +31,7 @@ enum class SendProgressType {
|
||||||
ChooseLocation,
|
ChooseLocation,
|
||||||
ChooseContact,
|
ChooseContact,
|
||||||
PlayGame,
|
PlayGame,
|
||||||
|
Speaking,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SendProgress {
|
struct SendProgress {
|
||||||
|
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "calls/calls_group_call.h"
|
#include "calls/calls_group_call.h"
|
||||||
|
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
|
#include "api/api_send_progress.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "boxes/confirm_box.h"
|
#include "boxes/confirm_box.h"
|
||||||
|
@ -38,6 +39,7 @@ constexpr auto kMaxInvitePerSlice = 10;
|
||||||
constexpr auto kCheckLastSpokeInterval = 3 * crl::time(1000);
|
constexpr auto kCheckLastSpokeInterval = 3 * crl::time(1000);
|
||||||
constexpr auto kSpeakLevelThreshold = 0.2;
|
constexpr auto kSpeakLevelThreshold = 0.2;
|
||||||
constexpr auto kCheckJoinedTimeout = 4 * crl::time(1000);
|
constexpr auto kCheckJoinedTimeout = 4 * crl::time(1000);
|
||||||
|
constexpr auto kUpdateSendActionEach = crl::time(500);
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -47,6 +49,7 @@ GroupCall::GroupCall(
|
||||||
const MTPInputGroupCall &inputCall)
|
const MTPInputGroupCall &inputCall)
|
||||||
: _delegate(delegate)
|
: _delegate(delegate)
|
||||||
, _channel(channel)
|
, _channel(channel)
|
||||||
|
, _history(channel->owner().history(channel))
|
||||||
, _api(&_channel->session().mtp())
|
, _api(&_channel->session().mtp())
|
||||||
, _lastSpokeCheckTimer([=] { checkLastSpoke(); })
|
, _lastSpokeCheckTimer([=] { checkLastSpoke(); })
|
||||||
, _checkJoinedTimer([=] { checkJoined(); }) {
|
, _checkJoinedTimer([=] { checkJoined(); }) {
|
||||||
|
@ -154,9 +157,11 @@ void GroupCall::join(const MTPInputGroupCall &inputCall) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupCall::rejoin() {
|
void GroupCall::rejoin() {
|
||||||
Expects(_state.current() == State::Joining
|
if (state() != State::Joining
|
||||||
|| _state.current() == State::Joined
|
&& state() != State::Joined
|
||||||
|| _state.current() == State::Connecting);
|
&& state() != State::Connecting) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_mySsrc = 0;
|
_mySsrc = 0;
|
||||||
setState(State::Joining);
|
setState(State::Joining);
|
||||||
|
@ -491,14 +496,23 @@ void GroupCall::handleLevelsUpdated(
|
||||||
auto checkNow = false;
|
auto checkNow = false;
|
||||||
const auto now = crl::now();
|
const auto now = crl::now();
|
||||||
for (const auto &[source, level] : data) {
|
for (const auto &[source, level] : data) {
|
||||||
|
const auto self = (source == _mySsrc);
|
||||||
_levelUpdates.fire(LevelUpdate{
|
_levelUpdates.fire(LevelUpdate{
|
||||||
.source = source,
|
.source = source,
|
||||||
.value = level,
|
.value = level,
|
||||||
.self = (source == _mySsrc)
|
.self = self
|
||||||
});
|
});
|
||||||
if (level <= kSpeakLevelThreshold) {
|
if (level <= kSpeakLevelThreshold) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (self
|
||||||
|
&& (!_lastSendProgressUpdate
|
||||||
|
|| _lastSendProgressUpdate + kUpdateSendActionEach < now)) {
|
||||||
|
_lastSendProgressUpdate = now;
|
||||||
|
_channel->session().sendProgressManager().update(
|
||||||
|
_history,
|
||||||
|
Api::SendProgressType::Speaking);
|
||||||
|
}
|
||||||
|
|
||||||
check = true;
|
check = true;
|
||||||
const auto i = _lastSpoke.find(source);
|
const auto i = _lastSpoke.find(source);
|
||||||
|
|
|
@ -13,6 +13,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "mtproto/sender.h"
|
#include "mtproto/sender.h"
|
||||||
#include "mtproto/mtproto_auth_key.h"
|
#include "mtproto/mtproto_auth_key.h"
|
||||||
|
|
||||||
|
class History;
|
||||||
|
|
||||||
namespace tgcalls {
|
namespace tgcalls {
|
||||||
class GroupInstanceImpl;
|
class GroupInstanceImpl;
|
||||||
} // namespace tgcalls
|
} // namespace tgcalls
|
||||||
|
@ -135,6 +137,7 @@ private:
|
||||||
|
|
||||||
const not_null<Delegate*> _delegate;
|
const not_null<Delegate*> _delegate;
|
||||||
const not_null<ChannelData*> _channel;
|
const not_null<ChannelData*> _channel;
|
||||||
|
const not_null<History*> _history;
|
||||||
MTP::Sender _api;
|
MTP::Sender _api;
|
||||||
rpl::variable<State> _state = State::Creating;
|
rpl::variable<State> _state = State::Creating;
|
||||||
bool _instanceConnected = false;
|
bool _instanceConnected = false;
|
||||||
|
@ -154,6 +157,8 @@ private:
|
||||||
base::Timer _lastSpokeCheckTimer;
|
base::Timer _lastSpokeCheckTimer;
|
||||||
base::Timer _checkJoinedTimer;
|
base::Timer _checkJoinedTimer;
|
||||||
|
|
||||||
|
crl::time _lastSendProgressUpdate = 0;
|
||||||
|
|
||||||
rpl::lifetime _lifetime;
|
rpl::lifetime _lifetime;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -115,7 +115,7 @@ void GroupCallSettingsBox(
|
||||||
),
|
),
|
||||||
st::groupCallSettingsButton
|
st::groupCallSettingsButton
|
||||||
)->addClickHandler([=] {
|
)->addClickHandler([=] {
|
||||||
box->getDelegate()->show(ChooseAudioInputBox(crl::guard(box, [=](
|
box->getDelegate()->show(ChooseAudioOutputBox(crl::guard(box, [=](
|
||||||
const QString &id,
|
const QString &id,
|
||||||
const QString &name) {
|
const QString &name) {
|
||||||
state->outputNameStream.fire_copy(name);
|
state->outputNameStream.fire_copy(name);
|
||||||
|
|
|
@ -51,9 +51,9 @@ bool SendActionPainter::updateNeedsAnimating(
|
||||||
|
|
||||||
const auto now = crl::now();
|
const auto now = crl::now();
|
||||||
const auto emplaceAction = [&](
|
const auto emplaceAction = [&](
|
||||||
Type type,
|
Type type,
|
||||||
crl::time duration,
|
crl::time duration,
|
||||||
int progress = 0) {
|
int progress = 0) {
|
||||||
_sendActions.emplace_or_assign(user, type, now + duration, progress);
|
_sendActions.emplace_or_assign(user, type, now + duration, progress);
|
||||||
};
|
};
|
||||||
action.match([&](const MTPDsendMessageTypingAction &) {
|
action.match([&](const MTPDsendMessageTypingAction &) {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 84b3ac9b58626f29952b8a0589e950893bfc0577
|
Subproject commit c4df097339aa7edf1d7aadde4df4a954971a3afb
|
Loading…
Add table
Reference in a new issue