/* 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 "data/data_user_names.h" #include "mtproto/sender.h" class ApiWrap; class PeerData; namespace Main { class Session; } // namespace Main namespace Api { class Usernames final { public: enum class Error { TooMuch, Unknown, }; explicit Usernames(not_null api); [[nodiscard]] rpl::producer loadUsernames( not_null peer) const; [[nodiscard]] rpl::producer toggle( not_null peer, const QString &username, bool active); [[nodiscard]] rpl::producer<> reorder( not_null peer, const std::vector &usernames); void requestToCache(not_null peer); [[nodiscard]] Data::Usernames cacheFor(PeerId id); static Data::Usernames FromTL(const MTPVector &usernames); private: const not_null _session; MTP::Sender _api; using Key = PeerId; struct Entry final { rpl::event_stream done; std::vector usernames; }; base::flat_map _toggleRequests; base::flat_map _reorderRequests; // Used for a seamless display of usernames list. std::pair _tinyCache; }; } // namespace Api