recent_peers.h 882 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. namespace Main {
  9. class Session;
  10. } // namespace Main
  11. namespace Data {
  12. class RecentPeers final {
  13. public:
  14. explicit RecentPeers(not_null<Main::Session*> session);
  15. ~RecentPeers();
  16. [[nodiscard]] const std::vector<not_null<PeerData*>> &list() const;
  17. [[nodiscard]] rpl::producer<> updates() const;
  18. void remove(not_null<PeerData*> peer);
  19. void bump(not_null<PeerData*> peer);
  20. void clear();
  21. [[nodiscard]] QByteArray serialize() const;
  22. void applyLocal(QByteArray serialized);
  23. private:
  24. const not_null<Main::Session*> _session;
  25. std::vector<not_null<PeerData*>> _list;
  26. rpl::event_stream<> _updates;
  27. };
  28. } // namespace Data