Track call_active flag in channels.

This commit is contained in:
John Preston 2020-12-01 16:22:07 +03:00
parent 43ee8a402c
commit 5a324756fd
4 changed files with 26 additions and 22 deletions

View file

@ -662,4 +662,4 @@ groupCallBoxLabel: FlatLabel(boxLabel) {
} }
groupCallRowBlobMinRadius: 28px; groupCallRowBlobMinRadius: 28px;
groupCallRowBlobMaxRadius: 31px; groupCallRowBlobMaxRadius: 30px;

View file

@ -156,7 +156,6 @@ private:
std::unique_ptr<Ui::RippleAnimation> _actionRipple; std::unique_ptr<Ui::RippleAnimation> _actionRipple;
std::unique_ptr<SpeakingAnimation> _speakingAnimation; std::unique_ptr<SpeakingAnimation> _speakingAnimation;
uint32 _ssrc = 0; uint32 _ssrc = 0;
float _level = 0.;
bool _speaking = false; bool _speaking = false;
}; };

View file

@ -49,27 +49,28 @@ ChannelData::ChannelData(not_null<Data::Session*> owner, PeerId id)
: PeerData(owner, id) : PeerData(owner, id)
, inputChannel(MTP_inputChannel(MTP_int(bareId()), MTP_long(0))) , inputChannel(MTP_inputChannel(MTP_int(bareId()), MTP_long(0)))
, _ptsWaiter(&owner->session().updates()) { , _ptsWaiter(&owner->session().updates()) {
Data::PeerFlagValue( _flags.changes(
this, ) | rpl::start_with_next([=](const Flags::Change &change) {
MTPDchannel::Flag::f_megagroup if (change.diff
) | rpl::start_with_next([=](bool megagroup) { & (MTPDchannel::Flag::f_left | MTPDchannel_ClientFlag::f_forbidden)) {
if (megagroup) { if (const auto chat = getMigrateFromChat()) {
session().changes().peerUpdated(chat, UpdateFlag::Migration);
session().changes().peerUpdated(this, UpdateFlag::Migration);
}
}
if (change.diff & MTPDchannel::Flag::f_megagroup) {
if (change.value & MTPDchannel::Flag::f_megagroup) {
if (!mgInfo) { if (!mgInfo) {
mgInfo = std::make_unique<MegagroupInfo>(); mgInfo = std::make_unique<MegagroupInfo>();
} }
} else if (mgInfo) { } else if (mgInfo) {
mgInfo = nullptr; mgInfo = nullptr;
} }
}, _lifetime); }
if (change.diff & MTPDchannel::Flag::f_call_active) {
Data::PeerFlagsValue( if (const auto history = this->owner().historyLoaded(this)) {
this, history->updateChatListEntry();
MTPDchannel::Flag::f_left | MTPDchannel_ClientFlag::f_forbidden }
) | rpl::distinct_until_changed(
) | rpl::start_with_next([=] {
if (const auto chat = getMigrateFromChat()) {
session().changes().peerUpdated(chat, UpdateFlag::Migration);
session().changes().peerUpdated(this, UpdateFlag::Migration);
} }
}, _lifetime); }, _lifetime);
} }
@ -686,7 +687,8 @@ void ChannelData::setCall(const MTPInputGroupCall &call) {
clearCall(); clearCall();
return; return;
} }
if (_call) { const auto hasCall = (_call != nullptr);
if (hasCall) {
owner().unregisterGroupCall(_call.get()); owner().unregisterGroupCall(_call.get());
} }
_call = std::make_unique<Data::GroupCall>( _call = std::make_unique<Data::GroupCall>(
@ -695,6 +697,7 @@ void ChannelData::setCall(const MTPInputGroupCall &call) {
data.vaccess_hash().v); data.vaccess_hash().v);
owner().registerGroupCall(_call.get()); owner().registerGroupCall(_call.get());
session().changes().peerUpdated(this, UpdateFlag::GroupCall); session().changes().peerUpdated(this, UpdateFlag::GroupCall);
addFlags(MTPDchannel::Flag::f_call_active);
}); });
} }
@ -705,6 +708,7 @@ void ChannelData::clearCall() {
owner().unregisterGroupCall(_call.get()); owner().unregisterGroupCall(_call.get());
_call = nullptr; _call = nullptr;
session().changes().peerUpdated(this, UpdateFlag::GroupCall); session().changes().peerUpdated(this, UpdateFlag::GroupCall);
removeFlags(MTPDchannel::Flag::f_call_active);
} }
namespace Data { namespace Data {

View file

@ -102,6 +102,7 @@ public:
| MTPDchannel::Flag::f_restricted | MTPDchannel::Flag::f_restricted
| MTPDchannel::Flag::f_signatures | MTPDchannel::Flag::f_signatures
| MTPDchannel::Flag::f_username | MTPDchannel::Flag::f_username
| MTPDchannel::Flag::f_call_active
| MTPDchannel::Flag::f_slowmode_enabled; | MTPDchannel::Flag::f_slowmode_enabled;
using Flags = Data::Flags< using Flags = Data::Flags<
MTPDchannel::Flags, MTPDchannel::Flags,