2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-01 23:15:59 +00:00

Use folder_id / still_unread_count from updates.

This commit is contained in:
John Preston
2019-04-23 13:40:14 +04:00
parent 01d5589594
commit 2d1dcb36cb
17 changed files with 343 additions and 224 deletions

View File

@@ -186,7 +186,7 @@ namespace Data {
void ApplyChatUpdate(
not_null<ChatData*> chat,
const MTPDupdateChatParticipants &update) {
ApplyChatParticipants(chat, update.vparticipants);
ApplyChatUpdate(chat, update.vparticipants);
}
void ApplyChatUpdate(
@@ -317,7 +317,44 @@ void ApplyChatUpdate(
chat->setDefaultRestrictions(update.vdefault_banned_rights);
}
void ApplyChatParticipants(
void ApplyChatUpdate(not_null<ChatData*> chat, const MTPDchatFull &update) {
ApplyChatUpdate(chat, update.vparticipants);
if (update.has_bot_info()) {
for (const auto &item : update.vbot_info.v) {
item.match([&](const MTPDbotInfo &data) {
const auto userId = data.vuser_id.v;
if (const auto bot = chat->owner().userLoaded(userId)) {
bot->setBotInfo(item);
chat->session().api().fullPeerUpdated().notify(bot);
}
});
}
}
chat->setFullFlags(update.vflags.v);
chat->setUserpicPhoto(update.has_chat_photo()
? update.vchat_photo
: MTPPhoto(MTP_photoEmpty(MTP_long(0))));
chat->setInviteLink(update.vexported_invite.match([&](
const MTPDchatInviteExported &data) {
return qs(data.vlink);
}, [&](const MTPDchatInviteEmpty &) {
return QString();
}));
if (update.has_pinned_msg_id()) {
chat->setPinnedMessageId(update.vpinned_msg_id.v);
} else {
chat->clearPinnedMessage();
}
chat->checkFolder(update.has_folder_id() ? update.vfolder_id.v : 0);
chat->fullUpdated();
chat->session().api().applyNotifySettings(
MTP_inputNotifyPeer(chat->input),
update.vnotify_settings);
}
void ApplyChatUpdate(
not_null<ChatData*> chat,
const MTPChatParticipants &participants) {
participants.match([&](const MTPDchatParticipantsForbidden &data) {