mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Change shown top senders only on amount change.
This commit is contained in:
parent
3001464f6b
commit
63f0feaf04
1 changed files with 10 additions and 1 deletions
|
@ -247,6 +247,8 @@ void FillTopReactors(
|
||||||
struct State {
|
struct State {
|
||||||
std::vector<not_null<RpWidget*>> widgets;
|
std::vector<not_null<RpWidget*>> widgets;
|
||||||
rpl::event_stream<> updated;
|
rpl::event_stream<> updated;
|
||||||
|
std::optional<int> initialChosen;
|
||||||
|
bool chosenChanged = false;
|
||||||
};
|
};
|
||||||
const auto state = wrap->lifetime().make_state<State>();
|
const auto state = wrap->lifetime().make_state<State>();
|
||||||
|
|
||||||
|
@ -254,6 +256,11 @@ void FillTopReactors(
|
||||||
std::move(chosen),
|
std::move(chosen),
|
||||||
std::move(anonymous)
|
std::move(anonymous)
|
||||||
) | rpl::start_with_next([=](int chosen, bool 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) {
|
for (const auto &widget : state->widgets) {
|
||||||
delete widget;
|
delete widget;
|
||||||
}
|
}
|
||||||
|
@ -266,7 +273,9 @@ void FillTopReactors(
|
||||||
list.push_back(entry);
|
list.push_back(entry);
|
||||||
} else if (!entry.click == anonymous) {
|
} else if (!entry.click == anonymous) {
|
||||||
auto copy = entry;
|
auto copy = entry;
|
||||||
copy.count += chosen;
|
if (state->chosenChanged) {
|
||||||
|
copy.count += chosen;
|
||||||
|
}
|
||||||
list.push_back(copy);
|
list.push_back(copy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue