From dd53d8df479b1ec12aee6f8181a5a8458c1a68b5 Mon Sep 17 00:00:00 2001 From: RadRussianRus Date: Tue, 6 Apr 2021 03:52:04 +0300 Subject: [PATCH] Fix refreshing of file references --- Telegram/SourceFiles/apiwrap.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index be1a30a4b..4a218c572 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -3947,6 +3947,7 @@ void ApiWrap::forwardMessagesUnquoted( && error.type().startsWith(qstr("FILE_REFERENCE_"))) { auto refreshRequests = mediaRefs->size(); auto index = 0; + auto wasUpdated = false; for (auto i = fromIter, e = toIter; i != e; i++) { const auto item = *i; const auto media = item->media(); @@ -3955,17 +3956,21 @@ void ApiWrap::forwardMessagesUnquoted( : Data::FileOrigin(); const auto usedFileReference = mediaRefs->value(index); - refreshFileReference(origin, [=, &refreshRequests](const auto &result) { - if (refreshRequests > 0) { - refreshRequests--; - return; - } - + refreshFileReference(origin, [=, &refreshRequests, &wasUpdated](const auto &result) { const auto currentMediaReference = media->photo() ? media->photo()->fileReference() : media->document()->fileReference(); if (currentMediaReference != usedFileReference) { + wasUpdated = true; + } + + if (refreshRequests > 0) { + refreshRequests--; + return; + } + + if (wasUpdated) { repeatRequest(repeatRequest); } else { sendMessageFail(error, peer);