mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 10:11:41 -05:00
fixed reading recent inline bots, fixed cached photos inline results, beta 9015006
This commit is contained in:
parent
cb2df51af6
commit
67d77bd114
2 changed files with 66 additions and 54 deletions
|
@ -1529,13 +1529,14 @@ LayoutInlineGif::~LayoutInlineGif() {
|
|||
}
|
||||
|
||||
void LayoutInlineGif::prepareThumb(int32 width, int32 height, const QSize &frame) const {
|
||||
if (_doc && !_doc->thumb->isNull()) {
|
||||
if (_doc->thumb->loaded()) {
|
||||
DocumentData *doc = _doc ? _doc : (_result ? _result->doc : 0);
|
||||
if (doc && !doc->thumb->isNull()) {
|
||||
if (doc->thumb->loaded()) {
|
||||
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 {
|
||||
_doc->thumb->load();
|
||||
doc->thumb->load();
|
||||
}
|
||||
} else if (_result && !_result->thumb_url.isEmpty()) {
|
||||
if (_result->thumb->loaded()) {
|
||||
|
@ -1746,19 +1747,20 @@ QSize LayoutInlinePhoto::countFrameSize() const {
|
|||
}
|
||||
|
||||
void LayoutInlinePhoto::prepareThumb(int32 width, int32 height, const QSize &frame) const {
|
||||
if (_photo) {
|
||||
if (_photo->medium->loaded()) {
|
||||
PhotoData *photo = _photo ? _photo : (_result ? _result->photo : 0);
|
||||
if (photo) {
|
||||
if (photo->medium->loaded()) {
|
||||
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;
|
||||
} else {
|
||||
if (_photo->thumb->loaded()) {
|
||||
if (photo->thumb->loaded()) {
|
||||
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 {
|
||||
if (_result->thumb->loaded()) {
|
||||
|
|
|
@ -3326,10 +3326,12 @@ namespace Local {
|
|||
StorageImageLocation photoLoc(_readStorageImageLocation(from));
|
||||
|
||||
result = App::peerLoaded(peerId);
|
||||
if (result && result->loaded) return result;
|
||||
bool wasLoaded = (result && result->loaded);
|
||||
|
||||
result = App::peer(peerId);
|
||||
result->loaded = true;
|
||||
if (!wasLoaded) {
|
||||
result = App::peer(peerId);
|
||||
result->loaded = true;
|
||||
}
|
||||
if (result->isUser()) {
|
||||
UserData *user = result->asUser();
|
||||
|
||||
|
@ -3348,26 +3350,28 @@ namespace Local {
|
|||
bool showPhone = !isServiceUser(user->id) && (peerToUser(user->id) != MTP::authedId()) && (contact <= 0);
|
||||
QString pname = (showPhone && !phone.isEmpty()) ? App::formatPhone(phone) : QString();
|
||||
|
||||
user->setName(first, last, pname, username);
|
||||
if (!wasLoaded) {
|
||||
user->setName(first, last, pname, username);
|
||||
|
||||
user->access = access;
|
||||
user->flags = flags;
|
||||
user->onlineTill = onlineTill;
|
||||
user->contact = contact;
|
||||
user->setBotInfoVersion(botInfoVersion);
|
||||
if (!inlinePlaceholder.isEmpty() && user->botInfo) {
|
||||
user->botInfo->inlinePlaceholder = inlinePlaceholder;
|
||||
user->access = access;
|
||||
user->flags = flags;
|
||||
user->onlineTill = onlineTill;
|
||||
user->contact = contact;
|
||||
user->setBotInfoVersion(botInfoVersion);
|
||||
if (!inlinePlaceholder.isEmpty() && user->botInfo) {
|
||||
user->botInfo->inlinePlaceholder = inlinePlaceholder;
|
||||
}
|
||||
|
||||
if (peerToUser(user->id) == MTP::authedId()) {
|
||||
user->input = MTP_inputPeerSelf();
|
||||
user->inputUser = MTP_inputUserSelf();
|
||||
} else {
|
||||
user->input = MTP_inputPeerUser(MTP_int(peerToUser(user->id)), MTP_long((user->access == UserNoAccess) ? 0 : user->access));
|
||||
user->inputUser = MTP_inputUser(MTP_int(peerToUser(user->id)), MTP_long((user->access == UserNoAccess) ? 0 : user->access));
|
||||
}
|
||||
|
||||
user->photo = photoLoc.isNull() ? ImagePtr(userDefPhoto(user->colorIndex)) : ImagePtr(photoLoc);
|
||||
}
|
||||
|
||||
if (peerToUser(user->id) == MTP::authedId()) {
|
||||
user->input = MTP_inputPeerSelf();
|
||||
user->inputUser = MTP_inputUserSelf();
|
||||
} else {
|
||||
user->input = MTP_inputPeerUser(MTP_int(peerToUser(user->id)), MTP_long((user->access == UserNoAccess) ? 0 : user->access));
|
||||
user->inputUser = MTP_inputUser(MTP_int(peerToUser(user->id)), MTP_long((user->access == UserNoAccess) ? 0 : user->access));
|
||||
}
|
||||
|
||||
user->photo = photoLoc.isNull() ? ImagePtr(userDefPhoto(user->colorIndex)) : ImagePtr(photoLoc);
|
||||
} else if (result->isChat()) {
|
||||
ChatData *chat = result->asChat();
|
||||
|
||||
|
@ -3381,19 +3385,21 @@ namespace Local {
|
|||
// flagsData was haveLeft
|
||||
flags = (flagsData == 1 ? MTPDchat::flag_left : 0);
|
||||
}
|
||||
chat->updateName(name, QString(), QString());
|
||||
chat->count = count;
|
||||
chat->date = date;
|
||||
chat->version = version;
|
||||
chat->creator = creator;
|
||||
chat->isForbidden = (forbidden == 1);
|
||||
chat->flags = flags;
|
||||
chat->invitationUrl = invitationUrl;
|
||||
if (!wasLoaded) {
|
||||
chat->updateName(name, QString(), QString());
|
||||
chat->count = count;
|
||||
chat->date = date;
|
||||
chat->version = version;
|
||||
chat->creator = creator;
|
||||
chat->isForbidden = (forbidden == 1);
|
||||
chat->flags = flags;
|
||||
chat->invitationUrl = invitationUrl;
|
||||
|
||||
chat->input = MTP_inputPeerChat(MTP_int(peerToChat(chat->id)));
|
||||
chat->inputChat = MTP_int(peerToChat(chat->id));
|
||||
chat->input = MTP_inputPeerChat(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()) {
|
||||
ChannelData *channel = result->asChannel();
|
||||
|
||||
|
@ -3402,21 +3408,25 @@ namespace Local {
|
|||
qint32 date, version, adminned, forbidden, flags;
|
||||
from.stream >> name >> access >> date >> version >> forbidden >> flags >> invitationUrl;
|
||||
|
||||
channel->updateName(name, QString(), QString());
|
||||
channel->access = access;
|
||||
channel->date = date;
|
||||
channel->version = version;
|
||||
channel->isForbidden = (forbidden == 1);
|
||||
channel->flags = flags;
|
||||
channel->invitationUrl = invitationUrl;
|
||||
if (!wasLoaded) {
|
||||
channel->updateName(name, QString(), QString());
|
||||
channel->access = access;
|
||||
channel->date = date;
|
||||
channel->version = version;
|
||||
channel->isForbidden = (forbidden == 1);
|
||||
channel->flags = flags;
|
||||
channel->invitationUrl = invitationUrl;
|
||||
|
||||
channel->input = MTP_inputPeerChannel(MTP_int(peerToChannel(channel->id)), MTP_long(access));
|
||||
channel->inputChannel = MTP_inputChannel(MTP_int(peerToChannel(channel->id)), MTP_long(access));
|
||||
channel->input = MTP_inputPeerChannel(MTP_int(peerToChannel(channel->id)), MTP_long(access));
|
||||
channel->inputChannel = MTP_inputChannel(MTP_int(peerToChannel(channel->id)), MTP_long(access));
|
||||
|
||||
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);
|
||||
emit App::main()->peerPhotoChanged(result);
|
||||
}
|
||||
App::markPeerUpdated(result);
|
||||
emit App::main()->peerPhotoChanged(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue