From 63f0feaf04f70a7e5df70ce2ea3d0211b3c13932 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 14 Aug 2024 17:56:56 +0200 Subject: [PATCH] Change shown top senders only on amount change. --- .../SourceFiles/payments/ui/payments_reaction_box.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/payments/ui/payments_reaction_box.cpp b/Telegram/SourceFiles/payments/ui/payments_reaction_box.cpp index f05006b1a..c6aaf796f 100644 --- a/Telegram/SourceFiles/payments/ui/payments_reaction_box.cpp +++ b/Telegram/SourceFiles/payments/ui/payments_reaction_box.cpp @@ -247,6 +247,8 @@ void FillTopReactors( struct State { std::vector> widgets; rpl::event_stream<> updated; + std::optional initialChosen; + bool chosenChanged = false; }; const auto state = wrap->lifetime().make_state(); @@ -254,6 +256,11 @@ void FillTopReactors( std::move(chosen), std::move(anonymous) ) | rpl::start_with_next([=](int chosen, bool anonymous) { + if (!state->initialChosen) { + state->initialChosen = chosen; + } else if (*state->initialChosen != chosen) { + state->chosenChanged = true; + } for (const auto &widget : state->widgets) { delete widget; } @@ -266,7 +273,9 @@ void FillTopReactors( list.push_back(entry); } else if (!entry.click == anonymous) { auto copy = entry; - copy.count += chosen; + if (state->chosenChanged) { + copy.count += chosen; + } list.push_back(copy); } }