Skip to content
Repos

DevPlaceApp

C++ 769 B26 lines Opens in site

Directory Raw Download

#pragma once
// Spec: INV-posts 7.4. Chips sorted by count (desc) then emoji (asc), truncated with a "..." chip that opens a popover.
#include <functional>
#include <string>
#include <vector>

#include "model/Reactions.hpp"
#include "ui/Views.hpp"

namespace dp {

struct ReactionItem {
  std::string emoji;
  std::int64_t count = 0;
  bool isMine = false;
};

class ReactionsStack {
 public:
  // Sorted items (count descending, emoji ascending by code unit order), capped at PostsLimits::kMaxReactionChips.
  static std::vector<ReactionItem> items(const Reactions& reactions);
  // nullptr (dropped by stacks) when there are no reactions.
  static ui::ViewPtr view(const Reactions& reactions, std::function<void(const std::string&)> onSelect);
};

}  // namespace dp
48.3ms