From 5277080115211ce717f00952444cd362ecbebc89 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 21 Jan 2021 23:33:22 +0300 Subject: [PATCH] Fixed adding caption to grouped files. Fixed #10192. --- .../ui/chat/attach/attach_prepare.cpp | 19 +++++++++++++++++++ .../ui/chat/attach/attach_prepare.h | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/ui/chat/attach/attach_prepare.cpp b/Telegram/SourceFiles/ui/chat/attach/attach_prepare.cpp index 8ba397094c..a2e3f21edc 100644 --- a/Telegram/SourceFiles/ui/chat/attach/attach_prepare.cpp +++ b/Telegram/SourceFiles/ui/chat/attach/attach_prepare.cpp @@ -152,6 +152,25 @@ bool PreparedList::canAddCaption(bool sendingAlbum) const { } else if (!sendingAlbum) { return false; } + + // All music. + { + auto pred = [](const PreparedFile &file) { + return file.type == PreparedFile::Type::Music; + }; + if (ranges::all_of(files, std::move(pred))) { + return true; + } + } + // All files. + { + auto pred = [](const PreparedFile &file) { + return file.type == PreparedFile::Type::File; + }; + if (ranges::all_of(files, std::move(pred))) { + return true; + } + } const auto hasFiles = ranges::contains( files, PreparedFile::Type::File, diff --git a/Telegram/SourceFiles/ui/chat/attach/attach_prepare.h b/Telegram/SourceFiles/ui/chat/attach/attach_prepare.h index fe7d5251d6..3f9ad04531 100644 --- a/Telegram/SourceFiles/ui/chat/attach/attach_prepare.h +++ b/Telegram/SourceFiles/ui/chat/attach/attach_prepare.h @@ -120,7 +120,7 @@ struct PreparedGroup { [[nodiscard]] bool sentWithCaption() const { return (list.files.size() == 1) - || (type == AlbumType::PhotoVideo); + || (type != AlbumType::None); } };