From cc9ae13297fa26c2d7c9d541bad86c5debf41c1e Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 13 Apr 2015 10:58:30 +0100 Subject: [PATCH] fixed vimeo links preview --- Telegram/SourceFiles/history.cpp | 14 ++++++++------ Telegram/SourceFiles/history.h | 8 ++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Telegram/SourceFiles/history.cpp b/Telegram/SourceFiles/history.cpp index 0f24e7460f..073a8a2deb 100644 --- a/Telegram/SourceFiles/history.cpp +++ b/Telegram/SourceFiles/history.cpp @@ -3257,17 +3257,19 @@ void HistoryWebPage::initDimensions(const HistoryItem *parent) { } } if (!data->description.isEmpty()) { + QString text = textClean(data->description); + if (!_asArticle) text += textcmdSkipBlock(parent->timeWidth(), st::msgDateFont->height - st::msgDateDelta.y()); + const TextParseOptions *opts = &_webpageDescriptionOptions; if (data->siteName == QLatin1String("Twitter")) { - _description.setText(st::webPageDescriptionFont, textClean(data->description), _twitterDescriptionOptions); + opts = &_twitterDescriptionOptions; } else if (data->siteName == QLatin1String("Instagram")) { - _description.setText(st::webPageDescriptionFont, textClean(data->description), _instagramDescriptionOptions); - } else { - _description.setText(st::webPageDescriptionFont, textClean(data->description), _webpageDescriptionOptions); + opts = &_instagramDescriptionOptions; } + _description.setText(st::webPageDescriptionFont, text, *opts); if (_asArticle) { _maxw = qMax(_maxw, int32(st::webPageLeft + _description.maxWidth() + st::webPagePhotoDelta + st::webPagePhotoSize)); } else { - _maxw = qMax(_maxw, int32(st::webPageLeft + _description.maxWidth() + parent->timeWidth())); + _maxw = qMax(_maxw, int32(st::webPageLeft + _description.maxWidth())); _minh += qMin(_description.minHeight(), 3 * st::webPageTitleFont->height); } } @@ -4443,7 +4445,7 @@ HistoryMedia *HistoryMessage::getMedia(bool inOverview) const { } void HistoryMessage::setMedia(const MTPmessageMedia &media) { - if (!_media && media.type() == mtpc_messageMediaEmpty) return; + if ((!_media || _media->isImageLink()) && media.type() == mtpc_messageMediaEmpty) return; if (_media) { delete _media; _media = 0; diff --git a/Telegram/SourceFiles/history.h b/Telegram/SourceFiles/history.h index 642a53c4b8..7d9384fa5c 100644 --- a/Telegram/SourceFiles/history.h +++ b/Telegram/SourceFiles/history.h @@ -802,6 +802,10 @@ public: virtual void updateFrom(const MTPMessageMedia &media) { } + virtual bool isImageLink() const { + return false; + } + virtual bool updateStickerEmoji() { return false; } @@ -1167,6 +1171,10 @@ public: void getState(TextLinkPtr &lnk, bool &inText, int32 x, int32 y, const HistoryItem *parent, int32 width = -1) const; HistoryMedia *clone() const; + bool isImageLink() const { + return true; + } + private: ImageLinkData *data; TextLinkPtr link;