From 830a3380823ceae3310536ac0def470227d60d55 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 28 Dec 2021 17:02:22 +0300 Subject: [PATCH] Sort reactions in bubbles correctly. --- .../history/view/history_view_reactions.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/history/view/history_view_reactions.cpp b/Telegram/SourceFiles/history/view/history_view_reactions.cpp index c8c5d788a..90bce941a 100644 --- a/Telegram/SourceFiles/history/view/history_view_reactions.cpp +++ b/Telegram/SourceFiles/history/view/history_view_reactions.cpp @@ -70,7 +70,16 @@ void InlineList::layoutButtons() { ) | ranges::view::transform([](const auto &pair) { return std::make_pair(pair.first, pair.second); }) | ranges::to_vector; - ranges::sort(sorted, std::greater<>(), &std::pair::second); + const auto &list = _owner->list(::Data::Reactions::Type::All); + ranges::sort(sorted, [&](const auto &p1, const auto &p2) { + if (p1.second > p2.second) { + return true; + } else if (p1.second < p2.second) { + return false; + } + return ranges::find(list, p1.first, &::Data::Reaction::emoji) + < ranges::find(list, p2.first, &::Data::Reaction::emoji); + }); auto buttons = std::vector