| 592 | } |
| 593 | |
| 594 | rpl::producer<Ui::WhoReadContent> WhoReacted( |
| 595 | not_null<HistoryItem*> item, |
| 596 | const ReactionId &reaction, |
| 597 | not_null<QWidget*> context, |
| 598 | const style::WhoRead &st, |
| 599 | std::shared_ptr<WhoReadList> whoReadIds) { |
| 600 | const auto small = st.userpics.size; |
| 601 | const auto large = st.photoSize; |
| 602 | return [=](auto consumer) { |
| 603 | auto lifetime = rpl::lifetime(); |
| 604 | |
| 605 | const auto resolveWhoRead = reaction.empty() |
| 606 | && WhoReadExists(item); |
| 607 | |
| 608 | const auto state = lifetime.make_state<State>(); |
| 609 | const auto pushNext = [=] { |
| 610 | consumer.put_next_copy(state->current); |
| 611 | }; |
| 612 | |
| 613 | const auto resolveWhoReacted = !reaction.empty() |
| 614 | || item->canViewReactions(); |
| 615 | auto idsWithReactions = (resolveWhoRead && resolveWhoReacted) |
| 616 | ? WhoReadOrReactedIds(item, context) |
| 617 | : resolveWhoRead |
| 618 | ? (WhoReadIds(item, context) | rpl::map(WithEmptyReactions)) |
| 619 | : WhoReactedIds(item, reaction, context); |
| 620 | state->current.type = resolveWhoRead |
| 621 | ? DetectSeenType(item) |
| 622 | : Ui::WhoReadType::Reacted; |
| 623 | if (resolveWhoReacted) { |
| 624 | const auto &list = item->reactions(); |
| 625 | state->current.fullReactionsCount = [&] { |
| 626 | if (reaction.empty()) { |
| 627 | return ranges::accumulate( |
| 628 | list, |
| 629 | 0, |
| 630 | ranges::plus{}, |
| 631 | &Data::MessageReaction::count); |
| 632 | } |
| 633 | const auto i = ranges::find( |
| 634 | list, |
| 635 | reaction, |
| 636 | &Data::MessageReaction::id); |
| 637 | return (i != end(list)) ? i->count : 0; |
| 638 | }(); |
| 639 | state->current.singleCustomEntityData = ReactionEntityData( |
| 640 | !reaction.empty() |
| 641 | ? reaction |
| 642 | : (list.size() == 1) |
| 643 | ? list.front().id |
| 644 | : ReactionId()); |
| 645 | } |
| 646 | std::move( |
| 647 | idsWithReactions |
| 648 | ) | rpl::on_next([=](PeersWithReactions &&peers) { |
| 649 | if (peers.state == WhoReadState::Unknown) { |
| 650 | state->userpics.clear(); |
| 651 | consumer.put_next(Ui::WhoReadContent{ |
no test coverage detected