/* 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 "ui/text/custom_emoji_instance.h" #include "base/timer.h" #include "base/weak_ptr.h" struct StickerSetIdentifier; namespace Main { class Session; } // namespace Main namespace Data { class Session; struct CustomEmojiId; class CustomEmojiLoader; class CustomEmojiManager final : public base::has_weak_ptr { public: enum class SizeTag { Normal, Large, }; CustomEmojiManager(not_null owner); ~CustomEmojiManager(); [[nodiscard]] std::unique_ptr create( const QString &data, Fn update); [[nodiscard]] Main::Session &session() const; [[nodiscard]] Session &owner() const; private: struct Set { int32 hash = 0; mtpRequestId requestId = 0; base::flat_set documents; base::flat_set waiting; }; struct RepaintBunch { crl::time when = 0; std::vector> instances; }; void requestSetIfNeeded(const CustomEmojiId &id); void repaintLater( not_null instance, Ui::CustomEmoji::RepaintRequest request); void scheduleRepaintTimer(); void invokeRepaints(); const not_null _owner; base::flat_map>> _instances; base::flat_map _sets; base::flat_map< uint64, std::vector>> _loaders; base::flat_map _repaints; crl::time _repaintNext = 0; base::Timer _repaintTimer; bool _repaintTimerScheduled = false; }; void FillTestCustomEmoji( not_null session, TextWithEntities &text); } // namespace Data