MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / WhoReacted

Function WhoReacted

Telegram/SourceFiles/api/api_who_reacted.cpp:594–699  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

592}
593
594rpl::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{

Callers 2

AddWhoReactedActionFunction · 0.85
ShowWhoReactedMenuFunction · 0.85

Calls 15

WhoReadExistsFunction · 0.85
WhoReadOrReactedIdsFunction · 0.85
WhoReadIdsFunction · 0.85
WhoReactedIdsFunction · 0.85
DetectSeenTypeFunction · 0.85
ReactionEntityDataFunction · 0.85
UpdateUserpicsFunction · 0.85
RegenerateParticipantsFunction · 0.85
RegenerateUserpicsFunction · 0.85
canViewReactionsMethod · 0.80
reactionsMethod · 0.80
frontMethod · 0.80

Tested by

no test coverage detected