/* This file is part of Telegram Desktop, the official desktop application for the Telegram messaging service. For license and copyright information please follow this link: https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once #include "mtproto/sender.h" #include "base/timer.h" class ApiWrap; class PeerData; namespace Main { class Session; } // namespace Main namespace Api { class ViewsManager final { public: explicit ViewsManager(not_null api); void scheduleIncrement(not_null item); void removeIncremented(not_null peer); void pollExtendedMedia(not_null item); private: struct PollExtendedMediaRequest { crl::time when = 0; mtpRequestId id = 0; base::flat_set ids; base::flat_set sent; }; void viewsIncrement(); void sendPollRequests(); void sendPollRequests( const base::flat_map< not_null, QVector> &prepared); void done( QVector ids, const MTPmessages_MessageViews &result, mtpRequestId requestId); void fail(const MTP::Error &error, mtpRequestId requestId); const not_null _session; MTP::Sender _api; base::flat_map, base::flat_set> _incremented; base::flat_map, base::flat_set> _toIncrement; base::flat_map, mtpRequestId> _incrementRequests; base::flat_map> _incrementByRequest; base::Timer _incrementTimer; base::flat_map< not_null, PollExtendedMediaRequest> _pollRequests; base::Timer _pollTimer; }; } // namespace Api