fixed reading recent inline bots, fixed cached photos inline results, beta 9015006

This commit is contained in:
John Preston 2016-01-01 23:08:56 +08:00
parent cb2df51af6
commit 67d77bd114
2 changed files with 66 additions and 54 deletions

View File

@ -1529,13 +1529,14 @@ LayoutInlineGif::~LayoutInlineGif() {
} }
void LayoutInlineGif::prepareThumb(int32 width, int32 height, const QSize &frame) const { void LayoutInlineGif::prepareThumb(int32 width, int32 height, const QSize &frame) const {
if (_doc && !_doc->thumb->isNull()) { DocumentData *doc = _doc ? _doc : (_result ? _result->doc : 0);
if (_doc->thumb->loaded()) { if (doc && !doc->thumb->isNull()) {
if (doc->thumb->loaded()) {
if (_thumb.width() != width * cIntRetinaFactor() || _thumb.height() != height * cIntRetinaFactor()) { if (_thumb.width() != width * cIntRetinaFactor() || _thumb.height() != height * cIntRetinaFactor()) {
_thumb = _doc->thumb->pixNoCache(frame.width() * cIntRetinaFactor(), frame.height() * cIntRetinaFactor(), true, false, false, width, height); _thumb = doc->thumb->pixNoCache(frame.width() * cIntRetinaFactor(), frame.height() * cIntRetinaFactor(), true, false, false, width, height);
} }
} else { } else {
_doc->thumb->load(); doc->thumb->load();
} }
} else if (_result && !_result->thumb_url.isEmpty()) { } else if (_result && !_result->thumb_url.isEmpty()) {
if (_result->thumb->loaded()) { if (_result->thumb->loaded()) {
@ -1746,19 +1747,20 @@ QSize LayoutInlinePhoto::countFrameSize() const {
} }
void LayoutInlinePhoto::prepareThumb(int32 width, int32 height, const QSize &frame) const { void LayoutInlinePhoto::prepareThumb(int32 width, int32 height, const QSize &frame) const {
if (_photo) { PhotoData *photo = _photo ? _photo : (_result ? _result->photo : 0);
if (_photo->medium->loaded()) { if (photo) {
if (photo->medium->loaded()) {
if (!_thumbLoaded || _thumb.width() != width * cIntRetinaFactor() || _thumb.height() != height * cIntRetinaFactor()) { if (!_thumbLoaded || _thumb.width() != width * cIntRetinaFactor() || _thumb.height() != height * cIntRetinaFactor()) {
_thumb = _photo->medium->pixNoCache(frame.width() * cIntRetinaFactor(), frame.height() * cIntRetinaFactor(), true, false, false, width, height); _thumb = photo->medium->pixNoCache(frame.width() * cIntRetinaFactor(), frame.height() * cIntRetinaFactor(), true, false, false, width, height);
} }
_thumbLoaded = true; _thumbLoaded = true;
} else { } else {
if (_photo->thumb->loaded()) { if (photo->thumb->loaded()) {
if (_thumb.width() != width * cIntRetinaFactor() || _thumb.height() != height * cIntRetinaFactor()) { if (_thumb.width() != width * cIntRetinaFactor() || _thumb.height() != height * cIntRetinaFactor()) {
_thumb = _photo->thumb->pixNoCache(frame.width() * cIntRetinaFactor(), frame.height() * cIntRetinaFactor(), true, false, false, width, height); _thumb = photo->thumb->pixNoCache(frame.width() * cIntRetinaFactor(), frame.height() * cIntRetinaFactor(), true, false, false, width, height);
} }
} }
_photo->medium->load(); photo->medium->load();
} }
} else { } else {
if (_result->thumb->loaded()) { if (_result->thumb->loaded()) {

View File

@ -3326,10 +3326,12 @@ namespace Local {
StorageImageLocation photoLoc(_readStorageImageLocation(from)); StorageImageLocation photoLoc(_readStorageImageLocation(from));
result = App::peerLoaded(peerId); result = App::peerLoaded(peerId);
if (result && result->loaded) return result; bool wasLoaded = (result && result->loaded);
if (!wasLoaded) {
result = App::peer(peerId); result = App::peer(peerId);
result->loaded = true; result->loaded = true;
}
if (result->isUser()) { if (result->isUser()) {
UserData *user = result->asUser(); UserData *user = result->asUser();
@ -3348,6 +3350,7 @@ namespace Local {
bool showPhone = !isServiceUser(user->id) && (peerToUser(user->id) != MTP::authedId()) && (contact <= 0); bool showPhone = !isServiceUser(user->id) && (peerToUser(user->id) != MTP::authedId()) && (contact <= 0);
QString pname = (showPhone && !phone.isEmpty()) ? App::formatPhone(phone) : QString(); QString pname = (showPhone && !phone.isEmpty()) ? App::formatPhone(phone) : QString();
if (!wasLoaded) {
user->setName(first, last, pname, username); user->setName(first, last, pname, username);
user->access = access; user->access = access;
@ -3368,6 +3371,7 @@ namespace Local {
} }
user->photo = photoLoc.isNull() ? ImagePtr(userDefPhoto(user->colorIndex)) : ImagePtr(photoLoc); user->photo = photoLoc.isNull() ? ImagePtr(userDefPhoto(user->colorIndex)) : ImagePtr(photoLoc);
}
} else if (result->isChat()) { } else if (result->isChat()) {
ChatData *chat = result->asChat(); ChatData *chat = result->asChat();
@ -3381,6 +3385,7 @@ namespace Local {
// flagsData was haveLeft // flagsData was haveLeft
flags = (flagsData == 1 ? MTPDchat::flag_left : 0); flags = (flagsData == 1 ? MTPDchat::flag_left : 0);
} }
if (!wasLoaded) {
chat->updateName(name, QString(), QString()); chat->updateName(name, QString(), QString());
chat->count = count; chat->count = count;
chat->date = date; chat->date = date;
@ -3394,6 +3399,7 @@ namespace Local {
chat->inputChat = MTP_int(peerToChat(chat->id)); chat->inputChat = MTP_int(peerToChat(chat->id));
chat->photo = photoLoc.isNull() ? ImagePtr(chatDefPhoto(chat->colorIndex)) : ImagePtr(photoLoc); chat->photo = photoLoc.isNull() ? ImagePtr(chatDefPhoto(chat->colorIndex)) : ImagePtr(photoLoc);
}
} else if (result->isChannel()) { } else if (result->isChannel()) {
ChannelData *channel = result->asChannel(); ChannelData *channel = result->asChannel();
@ -3402,6 +3408,7 @@ namespace Local {
qint32 date, version, adminned, forbidden, flags; qint32 date, version, adminned, forbidden, flags;
from.stream >> name >> access >> date >> version >> forbidden >> flags >> invitationUrl; from.stream >> name >> access >> date >> version >> forbidden >> flags >> invitationUrl;
if (!wasLoaded) {
channel->updateName(name, QString(), QString()); channel->updateName(name, QString(), QString());
channel->access = access; channel->access = access;
channel->date = date; channel->date = date;
@ -3415,8 +3422,11 @@ namespace Local {
channel->photo = photoLoc.isNull() ? ImagePtr((channel->isMegagroup() ? chatDefPhoto(channel->colorIndex) : channelDefPhoto(channel->colorIndex))) : ImagePtr(photoLoc); channel->photo = photoLoc.isNull() ? ImagePtr((channel->isMegagroup() ? chatDefPhoto(channel->colorIndex) : channelDefPhoto(channel->colorIndex))) : ImagePtr(photoLoc);
} }
}
if (!wasLoaded) {
App::markPeerUpdated(result); App::markPeerUpdated(result);
emit App::main()->peerPhotoChanged(result); emit App::main()->peerPhotoChanged(result);
}
return result; return result;
} }