From 2a3a38531b91ac2875ca74f5fef485d3e56b4365 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 12 Mar 2019 13:49:16 +0400 Subject: [PATCH] Fix photo inline result sending. Fixes #5594. --- Telegram/SourceFiles/data/data_session.cpp | 21 +++++++++++---------- Telegram/SourceFiles/data/data_session.h | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp index a1a43d7e26..76bf9726e1 100644 --- a/Telegram/SourceFiles/data/data_session.cpp +++ b/Telegram/SourceFiles/data/data_session.cpp @@ -1731,26 +1731,27 @@ void Session::photoConvert( PhotoData *Session::photoFromWeb( const MTPWebDocument &data, - ImagePtr thumbnailSmall, + ImagePtr thumbnail, bool willBecomeNormal) { const auto large = Images::Create(data); const auto thumbnailInline = ImagePtr(); if (large->isNull()) { return nullptr; } - auto thumbnail = large; + auto thumbnailSmall = large; if (willBecomeNormal) { const auto width = large->width(); const auto height = large->height(); - if (thumbnailSmall->isNull()) { - auto thumbsize = shrinkToKeepAspect(width, height, 100, 100); - thumbnailSmall = Images::Create(thumbsize.width(), thumbsize.height()); - } - auto mediumsize = shrinkToKeepAspect(width, height, 320, 320); - thumbnail = Images::Create(mediumsize.width(), mediumsize.height()); - } else if (thumbnailSmall->isNull()) { - thumbnailSmall = large; + auto thumbsize = shrinkToKeepAspect(width, height, 100, 100); + thumbnailSmall = Images::Create(thumbsize.width(), thumbsize.height()); + + if (thumbnail->isNull()) { + auto mediumsize = shrinkToKeepAspect(width, height, 320, 320); + thumbnail = Images::Create(mediumsize.width(), mediumsize.height()); + } + } else if (thumbnail->isNull()) { + thumbnail = large; } return photo( diff --git a/Telegram/SourceFiles/data/data_session.h b/Telegram/SourceFiles/data/data_session.h index d06663164f..1aef19fa1d 100644 --- a/Telegram/SourceFiles/data/data_session.h +++ b/Telegram/SourceFiles/data/data_session.h @@ -355,7 +355,7 @@ public: const MTPPhoto &data); [[nodiscard]] PhotoData *photoFromWeb( const MTPWebDocument &data, - ImagePtr thumbnailSmall = ImagePtr(), + ImagePtr thumbnail = ImagePtr(), bool willBecomeNormal = false); [[nodiscard]] not_null document(DocumentId id);