From 1a40f2b3ef62da21071e615e099a8ae06fc0f2db Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 17 Sep 2020 18:13:12 +0300 Subject: [PATCH] Fix userpics display for min-loaded users. --- Telegram/SourceFiles/data/data_channel.h | 2 +- Telegram/SourceFiles/data/data_chat.h | 2 +- Telegram/SourceFiles/data/data_peer.h | 2 +- Telegram/SourceFiles/data/data_session.cpp | 14 ++++++++++++++ Telegram/SourceFiles/data/data_user.h | 2 +- Telegram/SourceFiles/storage/serialize_peer.cpp | 1 - 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/data/data_channel.h b/Telegram/SourceFiles/data/data_channel.h index ffeeec06e8..418e4a724d 100644 --- a/Telegram/SourceFiles/data/data_channel.h +++ b/Telegram/SourceFiles/data/data_channel.h @@ -396,7 +396,7 @@ public: // Still public data members. uint64 access = 0; - MTPinputChannel inputChannel; + MTPinputChannel inputChannel = MTP_inputChannelEmpty(); QString username; diff --git a/Telegram/SourceFiles/data/data_chat.h b/Telegram/SourceFiles/data/data_chat.h index ed99c6d63a..3084767cb5 100644 --- a/Telegram/SourceFiles/data/data_chat.h +++ b/Telegram/SourceFiles/data/data_chat.h @@ -163,7 +163,7 @@ public: void setMigrateToChannel(ChannelData *channel); // Still public data members. - MTPint inputChat; + const MTPint inputChat; int count = 0; TimeId date = 0; diff --git a/Telegram/SourceFiles/data/data_peer.h b/Telegram/SourceFiles/data/data_peer.h index dad65e00fe..cd935e9e00 100644 --- a/Telegram/SourceFiles/data/data_peer.h +++ b/Telegram/SourceFiles/data/data_peer.h @@ -388,7 +388,7 @@ public: const PeerId id; QString name; - MTPinputPeer input; + MTPinputPeer input = MTP_inputPeerEmpty(); int nameVersion = 1; diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp index 836ed9f486..d9c5fec6da 100644 --- a/Telegram/SourceFiles/data/data_session.cpp +++ b/Telegram/SourceFiles/data/data_session.cpp @@ -398,6 +398,16 @@ not_null Session::processUser(const MTPUser &data) { //| MTPDuser_ClientFlag::f_inaccessible | MTPDuser::Flag::f_deleted; result->setFlags((result->flags() & ~mask) | (data.vflags().v & mask)); + if (result->input.type() == mtpc_inputPeerEmpty) { + result->input = MTP_inputPeerUser( + data.vid(), + MTP_long(data.vaccess_hash().value_or_empty())); + } + if (result->inputUser.type() == mtpc_inputUserEmpty) { + result->inputUser = MTP_inputUser( + data.vid(), + MTP_long(data.vaccess_hash().value_or_empty())); + } } else { result->setFlags(data.vflags().v); if (data.is_self()) { @@ -643,6 +653,10 @@ not_null Session::processChat(const MTPChat &data) { | MTPDchannel::Flag::f_megagroup | MTPDchannel_ClientFlag::f_forbidden; channel->setFlags((channel->flags() & ~mask) | (data.vflags().v & mask)); + if (channel->input.type() == mtpc_inputPeerEmpty + || channel->inputChannel.type() == mtpc_inputChannelEmpty) { + channel->setAccessHash(data.vaccess_hash().value_or_empty()); + } } else { if (const auto rights = data.vadmin_rights()) { channel->setAdminRights(*rights); diff --git a/Telegram/SourceFiles/data/data_user.h b/Telegram/SourceFiles/data/data_user.h index 299cedab84..bff3be7eca 100644 --- a/Telegram/SourceFiles/data/data_user.h +++ b/Telegram/SourceFiles/data/data_user.h @@ -155,7 +155,7 @@ public: return !_phone.isEmpty(); } - MTPInputUser inputUser; + MTPInputUser inputUser = MTP_inputUserEmpty(); QString firstName; QString lastName; diff --git a/Telegram/SourceFiles/storage/serialize_peer.cpp b/Telegram/SourceFiles/storage/serialize_peer.cpp index a97c194568..75b37305db 100644 --- a/Telegram/SourceFiles/storage/serialize_peer.cpp +++ b/Telegram/SourceFiles/storage/serialize_peer.cpp @@ -283,7 +283,6 @@ PeerData *readPeer( chat->setInviteLink(inviteLink); chat->input = MTP_inputPeerChat(MTP_int(peerToChat(chat->id))); - chat->inputChat = MTP_int(peerToChat(chat->id)); } } else if (const auto channel = result->asChannel()) { QString name, inviteLink;