From 5a324756fdf2ce8f93aa0603ad8dbc63370c6f7e Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 1 Dec 2020 16:22:07 +0300 Subject: [PATCH] Track call_active flag in channels. --- Telegram/SourceFiles/calls/calls.style | 2 +- .../SourceFiles/calls/calls_group_members.cpp | 1 - Telegram/SourceFiles/data/data_channel.cpp | 44 ++++++++++--------- Telegram/SourceFiles/data/data_channel.h | 1 + 4 files changed, 26 insertions(+), 22 deletions(-) diff --git a/Telegram/SourceFiles/calls/calls.style b/Telegram/SourceFiles/calls/calls.style index eccc821c2f..8daf150051 100644 --- a/Telegram/SourceFiles/calls/calls.style +++ b/Telegram/SourceFiles/calls/calls.style @@ -662,4 +662,4 @@ groupCallBoxLabel: FlatLabel(boxLabel) { } groupCallRowBlobMinRadius: 28px; -groupCallRowBlobMaxRadius: 31px; +groupCallRowBlobMaxRadius: 30px; diff --git a/Telegram/SourceFiles/calls/calls_group_members.cpp b/Telegram/SourceFiles/calls/calls_group_members.cpp index aafde86aa5..d8a1a80889 100644 --- a/Telegram/SourceFiles/calls/calls_group_members.cpp +++ b/Telegram/SourceFiles/calls/calls_group_members.cpp @@ -156,7 +156,6 @@ private: std::unique_ptr _actionRipple; std::unique_ptr _speakingAnimation; uint32 _ssrc = 0; - float _level = 0.; bool _speaking = false; }; diff --git a/Telegram/SourceFiles/data/data_channel.cpp b/Telegram/SourceFiles/data/data_channel.cpp index 9f5ed04feb..e972e4388c 100644 --- a/Telegram/SourceFiles/data/data_channel.cpp +++ b/Telegram/SourceFiles/data/data_channel.cpp @@ -49,27 +49,28 @@ ChannelData::ChannelData(not_null 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(); + _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(); + } + } 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( @@ -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 { diff --git a/Telegram/SourceFiles/data/data_channel.h b/Telegram/SourceFiles/data/data_channel.h index 372244ab84..b98dec3f4b 100644 --- a/Telegram/SourceFiles/data/data_channel.h +++ b/Telegram/SourceFiles/data/data_channel.h @@ -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,