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 {
 | 
					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()) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		result = App::peer(peerId);
 | 
							if (!wasLoaded) {
 | 
				
			||||||
		result->loaded = true;
 | 
								result = App::peer(peerId);
 | 
				
			||||||
 | 
								result->loaded = true;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		if (result->isUser()) {
 | 
							if (result->isUser()) {
 | 
				
			||||||
			UserData *user = result->asUser();
 | 
								UserData *user = result->asUser();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3348,26 +3350,28 @@ 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();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			user->setName(first, last, pname, username);
 | 
								if (!wasLoaded) {
 | 
				
			||||||
 | 
									user->setName(first, last, pname, username);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			user->access = access;
 | 
									user->access = access;
 | 
				
			||||||
			user->flags = flags;
 | 
									user->flags = flags;
 | 
				
			||||||
			user->onlineTill = onlineTill;
 | 
									user->onlineTill = onlineTill;
 | 
				
			||||||
			user->contact = contact;
 | 
									user->contact = contact;
 | 
				
			||||||
			user->setBotInfoVersion(botInfoVersion);
 | 
									user->setBotInfoVersion(botInfoVersion);
 | 
				
			||||||
			if (!inlinePlaceholder.isEmpty() && user->botInfo) {
 | 
									if (!inlinePlaceholder.isEmpty() && user->botInfo) {
 | 
				
			||||||
				user->botInfo->inlinePlaceholder = inlinePlaceholder;
 | 
										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()) {
 | 
							} else if (result->isChat()) {
 | 
				
			||||||
			ChatData *chat = result->asChat();
 | 
								ChatData *chat = result->asChat();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3381,19 +3385,21 @@ namespace Local {
 | 
				
			||||||
				// flagsData was haveLeft
 | 
									// flagsData was haveLeft
 | 
				
			||||||
				flags = (flagsData == 1 ? MTPDchat::flag_left : 0);
 | 
									flags = (flagsData == 1 ? MTPDchat::flag_left : 0);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			chat->updateName(name, QString(), QString());
 | 
								if (!wasLoaded) {
 | 
				
			||||||
			chat->count = count;
 | 
									chat->updateName(name, QString(), QString());
 | 
				
			||||||
			chat->date = date;
 | 
									chat->count = count;
 | 
				
			||||||
			chat->version = version;
 | 
									chat->date = date;
 | 
				
			||||||
			chat->creator = creator;
 | 
									chat->version = version;
 | 
				
			||||||
			chat->isForbidden = (forbidden == 1);
 | 
									chat->creator = creator;
 | 
				
			||||||
			chat->flags = flags;
 | 
									chat->isForbidden = (forbidden == 1);
 | 
				
			||||||
			chat->invitationUrl = invitationUrl;
 | 
									chat->flags = flags;
 | 
				
			||||||
 | 
									chat->invitationUrl = invitationUrl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			chat->input = MTP_inputPeerChat(MTP_int(peerToChat(chat->id)));
 | 
									chat->input = MTP_inputPeerChat(MTP_int(peerToChat(chat->id)));
 | 
				
			||||||
			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,21 +3408,25 @@ 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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			channel->updateName(name, QString(), QString());
 | 
								if (!wasLoaded) {
 | 
				
			||||||
			channel->access = access;
 | 
									channel->updateName(name, QString(), QString());
 | 
				
			||||||
			channel->date = date;
 | 
									channel->access = access;
 | 
				
			||||||
			channel->version = version;
 | 
									channel->date = date;
 | 
				
			||||||
			channel->isForbidden = (forbidden == 1);
 | 
									channel->version = version;
 | 
				
			||||||
			channel->flags = flags;
 | 
									channel->isForbidden = (forbidden == 1);
 | 
				
			||||||
			channel->invitationUrl = invitationUrl;
 | 
									channel->flags = flags;
 | 
				
			||||||
 | 
									channel->invitationUrl = invitationUrl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			channel->input = MTP_inputPeerChannel(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->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;
 | 
							return result;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue