Read "participants_count" field from c_channel().

This commit is contained in:
John Preston 2017-12-26 16:32:44 +03:00
parent 01821c30e5
commit 86c0dfb295
2 changed files with 18 additions and 10 deletions

View File

@ -519,26 +519,34 @@ namespace {
} }
} break; } break;
case mtpc_channel: { case mtpc_channel: {
auto &d = chat.c_channel(); const auto &d = chat.c_channel();
auto peerId = peerFromChannel(d.vid.v); const auto peerId = peerFromChannel(d.vid.v);
minimal = d.is_min(); minimal = d.is_min();
if (minimal) { if (minimal) {
data = App::channelLoaded(peerId); data = App::channelLoaded(peerId);
if (!data) { if (!data) {
return nullptr; // minimal is not loaded, need to make getDifference // Can't apply minimal to a not loaded channel.
// Need to make getDifference.
return nullptr;
} }
} else { } else {
data = App::channel(peerId); data = App::channel(peerId);
data->input = MTP_inputPeerChannel(d.vid, d.has_access_hash() ? d.vaccess_hash : MTP_long(0)); const auto accessHash = d.has_access_hash()
? d.vaccess_hash
: MTP_long(0);
data->input = MTP_inputPeerChannel(d.vid, accessHash);
} }
auto cdata = data->asChannel(); const auto cdata = data->asChannel();
auto wasInChannel = cdata->amIn(); const auto wasInChannel = cdata->amIn();
auto canViewAdmins = cdata->canViewAdmins(); const auto canViewAdmins = cdata->canViewAdmins();
auto canViewMembers = cdata->canViewMembers(); const auto canViewMembers = cdata->canViewMembers();
auto canAddMembers = cdata->canAddMembers(); const auto canAddMembers = cdata->canAddMembers();
if (d.has_participants_count()) {
cdata->setMembersCount(d.vparticipants_count.v);
}
if (minimal) { if (minimal) {
auto mask = 0 auto mask = 0
| MTPDchannel::Flag::f_broadcast | MTPDchannel::Flag::f_broadcast

View File

@ -327,7 +327,7 @@ void ConvertToSupergroupBox::convertDone(const MTPUpdates &updates) {
auto handleChats = [](auto &mtpChats) { auto handleChats = [](auto &mtpChats) {
for_const (auto &mtpChat, mtpChats.v) { for_const (auto &mtpChat, mtpChats.v) {
if (mtpChat.type() == mtpc_channel) { if (mtpChat.type() == mtpc_channel) {
auto channel = App::channel(mtpChat.c_channel().vid.v); const auto channel = App::channel(mtpChat.c_channel().vid.v);
Ui::showPeerHistory(channel, ShowAtUnreadMsgId); Ui::showPeerHistory(channel, ShowAtUnreadMsgId);
Auth().api().requestParticipantsCountDelayed(channel); Auth().api().requestParticipantsCountDelayed(channel);
} }