api_who_reacted.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. class HistoryItem;
  9. namespace style {
  10. struct WhoRead;
  11. } // namespace style
  12. namespace Ui {
  13. struct WhoReadContent;
  14. enum class WhoReadType;
  15. } // namespace Ui
  16. namespace Data {
  17. struct ReactionId;
  18. } // namespace Data
  19. namespace Api {
  20. enum class WhoReactedList {
  21. All,
  22. One,
  23. };
  24. [[nodiscard]] QString FormatReadDate(TimeId date, const QDateTime &now);
  25. [[nodiscard]] bool WhoReadExists(not_null<HistoryItem*> item);
  26. [[nodiscard]] bool WhoReactedExists(
  27. not_null<HistoryItem*> item,
  28. WhoReactedList list);
  29. struct WhoReadPeer {
  30. PeerId peer = 0;
  31. TimeId date = 0;
  32. bool dateReacted = false;
  33. friend inline bool operator==(
  34. const WhoReadPeer &a,
  35. const WhoReadPeer &b) noexcept = default;
  36. };
  37. struct WhoReadList {
  38. std::vector<WhoReadPeer> list;
  39. Ui::WhoReadType type = {};
  40. };
  41. // The context must be destroyed before the session holding this item.
  42. [[nodiscard]] rpl::producer<Ui::WhoReadContent> WhoReacted(
  43. not_null<HistoryItem*> item,
  44. not_null<QWidget*> context, // Cache results for this lifetime.
  45. const style::WhoRead &st,
  46. std::shared_ptr<WhoReadList> whoReadIds = nullptr);
  47. [[nodiscard]] rpl::producer<Ui::WhoReadContent> WhoReacted(
  48. not_null<HistoryItem*> item,
  49. const Data::ReactionId &reaction,
  50. not_null<QWidget*> context, // Cache results for this lifetime.
  51. const style::WhoRead &st);
  52. [[nodiscard]] rpl::producer<Ui::WhoReadContent> WhenEdited(
  53. not_null<PeerData*> author,
  54. TimeId date);
  55. [[nodiscard]] rpl::producer<Ui::WhoReadContent> WhenOriginal(
  56. not_null<PeerData*> author,
  57. TimeId date);
  58. } // namespace Api