data_saved_sublist.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. #include "dialogs/ui/dialogs_message_view.h"
  9. #include "dialogs/dialogs_entry.h"
  10. class PeerData;
  11. class History;
  12. namespace Data {
  13. class Session;
  14. class SavedSublist final : public Dialogs::Entry {
  15. public:
  16. explicit SavedSublist(not_null<PeerData*> peer);
  17. ~SavedSublist();
  18. [[nodiscard]] not_null<History*> history() const;
  19. [[nodiscard]] not_null<PeerData*> peer() const;
  20. [[nodiscard]] bool isHiddenAuthor() const;
  21. [[nodiscard]] bool isFullLoaded() const;
  22. [[nodiscard]] auto messages() const
  23. -> const std::vector<not_null<HistoryItem*>> &;
  24. void applyMaybeLast(not_null<HistoryItem*> item, bool added = false);
  25. void removeOne(not_null<HistoryItem*> item);
  26. void append(std::vector<not_null<HistoryItem*>> &&items, int fullCount);
  27. void setFullLoaded(bool loaded = true);
  28. [[nodiscard]] rpl::producer<> changes() const;
  29. [[nodiscard]] std::optional<int> fullCount() const;
  30. [[nodiscard]] rpl::producer<int> fullCountValue() const;
  31. [[nodiscard]] Dialogs::Ui::MessageView &lastItemDialogsView() {
  32. return _lastItemDialogsView;
  33. }
  34. int fixedOnTopIndex() const override;
  35. bool shouldBeInChatList() const override;
  36. Dialogs::UnreadState chatListUnreadState() const override;
  37. Dialogs::BadgesState chatListBadgesState() const override;
  38. HistoryItem *chatListMessage() const override;
  39. bool chatListMessageKnown() const override;
  40. const QString &chatListName() const override;
  41. const QString &chatListNameSortKey() const override;
  42. int chatListNameVersion() const override;
  43. const base::flat_set<QString> &chatListNameWords() const override;
  44. const base::flat_set<QChar> &chatListFirstLetters() const override;
  45. void chatListPreloadData() override;
  46. void paintUserpic(
  47. Painter &p,
  48. Ui::PeerUserpicView &view,
  49. const Dialogs::Ui::PaintContext &context) const override;
  50. private:
  51. enum class Flag : uchar {
  52. ResolveChatListMessage = (1 << 0),
  53. FullLoaded = (1 << 1),
  54. };
  55. friend inline constexpr bool is_flag_type(Flag) { return true; }
  56. using Flags = base::flags<Flag>;
  57. bool hasOrphanMediaGroupPart() const;
  58. void allowChatListMessageResolve();
  59. void resolveChatListMessageGroup();
  60. const not_null<History*> _history;
  61. std::vector<not_null<HistoryItem*>> _items;
  62. std::optional<int> _fullCount;
  63. rpl::event_stream<> _changed;
  64. Dialogs::Ui::MessageView _lastItemDialogsView;
  65. Flags _flags;
  66. };
  67. } // namespace Data