api_unread_things.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 ApiWrap;
  9. class PeerData;
  10. class ChannelData;
  11. namespace Data {
  12. class Thread;
  13. } // namespace Data
  14. namespace Api {
  15. class UnreadThings final {
  16. public:
  17. explicit UnreadThings(not_null<ApiWrap*> api);
  18. [[nodiscard]] bool trackMentions(Data::Thread *thread) const;
  19. [[nodiscard]] bool trackReactions(Data::Thread *thread) const;
  20. void preloadEnough(Data::Thread *thread);
  21. void mediaAndMentionsRead(
  22. const base::flat_set<MsgId> &readIds,
  23. ChannelData *channel = nullptr);
  24. void cancelRequests(not_null<Data::Thread*> thread);
  25. private:
  26. void preloadEnoughMentions(not_null<Data::Thread*> thread);
  27. void preloadEnoughReactions(not_null<Data::Thread*> thread);
  28. void requestMentions(not_null<Data::Thread*> thread, int loaded);
  29. void requestReactions(not_null<Data::Thread*> thread, int loaded);
  30. const not_null<ApiWrap*> _api;
  31. base::flat_map<not_null<Data::Thread*>, mtpRequestId> _mentionsRequests;
  32. base::flat_map<not_null<Data::Thread*>, mtpRequestId> _reactionsRequests;
  33. };
  34. } // namespace Api