/* 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/stickers/data_stickers_set.h" #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; class CustomEmojiLoader; struct CustomEmojiId { uint64 selfId = 0; uint64 id = 0; }; class CustomEmojiManager final : public base::has_weak_ptr { public: enum class SizeTag { Normal, Large, }; CustomEmojiManager(not_null owner); ~CustomEmojiManager(); [[nodiscard]] std::unique_ptr create( QStringView data, Fn update); [[nodiscard]] std::unique_ptr createLoader( not_null document, SizeTag tag); [[nodiscard]] Main::Session &session() const; [[nodiscard]] Session &owner() const; private: struct RepaintBunch { crl::time when = 0; std::vector> instances; }; void request(); void requestFinished(); void repaintLater( not_null instance, Ui::CustomEmoji::RepaintRequest request); void scheduleRepaintTimer(); void invokeRepaints(); const not_null _owner; base::flat_map< uint64, std::unique_ptr> _instances; base::flat_map< uint64, std::vector>> _loaders; base::flat_set _pendingForRequest; mtpRequestId _requestId = 0; base::flat_map _repaints; crl::time _repaintNext = 0; base::Timer _repaintTimer; bool _repaintTimerScheduled = false; }; [[nodiscard]] QString SerializeCustomEmojiId(const CustomEmojiId &id); [[nodiscard]] QString SerializeCustomEmojiId( not_null document); [[nodiscard]] CustomEmojiId ParseCustomEmojiData(QStringView data); void InsertCustomEmoji( not_null field, not_null document); } // namespace Data