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;
groupCallRowBlobMaxRadius: 31px;
groupCallRowBlobMaxRadius: 30px;

View file

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

View file

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

View file

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