2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Support new ('modern') API file locations.

This commit is contained in:
John Preston
2019-03-22 18:19:43 +04:00
parent eba2a98703
commit aa8f62da9d
41 changed files with 947 additions and 566 deletions

View File

@@ -1057,11 +1057,11 @@ void History::applyServiceChanges(
case mtpc_messageActionChatEditPhoto: {
auto &d = action.c_messageActionChatEditPhoto();
if (d.vphoto.type() == mtpc_photo) {
auto &sizes = d.vphoto.c_photo().vsizes.v;
d.vphoto.match([&](const MTPDphoto &data) {
const auto &sizes = data.vsizes.v;
if (!sizes.isEmpty()) {
auto photo = _owner->processPhoto(d.vphoto.c_photo());
if (photo) photo->peer = peer;
auto photo = _owner->processPhoto(data);
photo->peer = peer;
auto &smallSize = sizes.front();
auto &bigSize = sizes.back();
const MTPFileLocation *smallLoc = 0, *bigLoc = 0;
@@ -1074,16 +1074,21 @@ void History::applyServiceChanges(
case mtpc_photoCachedSize: bigLoc = &bigSize.c_photoCachedSize().vlocation; break;
}
if (smallLoc && bigLoc) {
const auto newPhotoId = photo ? photo->id : PhotoId();
if (const auto chat = peer->asChat()) {
chat->setPhoto(newPhotoId, MTP_chatPhoto(*smallLoc, *bigLoc));
chat->setPhoto(photo->id, MTP_chatPhoto(*smallLoc, *bigLoc, data.vdc_id));
} else if (const auto channel = peer->asChannel()) {
channel->setPhoto(newPhotoId, MTP_chatPhoto(*smallLoc, *bigLoc));
channel->setPhoto(photo->id, MTP_chatPhoto(*smallLoc, *bigLoc, data.vdc_id));
}
peer->loadUserpic();
}
}
}
}, [&](const MTPDphotoEmpty &data) {
if (const auto chat = peer->asChat()) {
chat->setPhoto(MTP_chatPhotoEmpty());
} else if (const auto channel = peer->asChannel()) {
channel->setPhoto(MTP_chatPhotoEmpty());
}
});
} break;
case mtpc_messageActionChatEditTitle: {