2022-06-23 13:52:15 +00:00
|
|
|
/*
|
|
|
|
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
|
|
|
|
|
2022-06-24 11:14:23 +00:00
|
|
|
#include "ui/text/custom_emoji_instance.h"
|
|
|
|
|
|
|
|
struct StickerSetIdentifier;
|
|
|
|
|
2022-06-23 13:52:15 +00:00
|
|
|
namespace Main {
|
|
|
|
class Session;
|
|
|
|
} // namespace Main
|
|
|
|
|
|
|
|
namespace Data {
|
|
|
|
|
|
|
|
class Session;
|
2022-06-24 11:14:23 +00:00
|
|
|
struct CustomEmojiId;
|
|
|
|
class CustomEmojiLoader;
|
2022-06-23 13:52:15 +00:00
|
|
|
|
|
|
|
class CustomEmojiManager final {
|
|
|
|
public:
|
|
|
|
CustomEmojiManager(not_null<Session*> owner);
|
|
|
|
~CustomEmojiManager();
|
|
|
|
|
|
|
|
[[nodiscard]] std::unique_ptr<Ui::Text::CustomEmoji> create(
|
2022-06-24 06:49:11 +00:00
|
|
|
const QString &data,
|
|
|
|
Fn<void()> update);
|
2022-06-23 13:52:15 +00:00
|
|
|
|
|
|
|
[[nodiscard]] Main::Session &session() const;
|
|
|
|
[[nodiscard]] Session &owner() const;
|
|
|
|
|
|
|
|
private:
|
2022-06-24 11:14:23 +00:00
|
|
|
struct Set {
|
|
|
|
int32 hash = 0;
|
|
|
|
mtpRequestId requestId = 0;
|
|
|
|
base::flat_set<uint64> documents;
|
|
|
|
base::flat_set<uint64> waiting;
|
|
|
|
};
|
|
|
|
|
|
|
|
void requestSetIfNeeded(const CustomEmojiId &id);
|
|
|
|
|
2022-06-23 13:52:15 +00:00
|
|
|
const not_null<Session*> _owner;
|
|
|
|
|
2022-06-24 11:14:23 +00:00
|
|
|
base::flat_map<uint64, base::flat_map<
|
|
|
|
uint64,
|
|
|
|
std::unique_ptr<Ui::CustomEmoji::Instance>>> _instances;
|
|
|
|
base::flat_map<uint64, Set> _sets;
|
|
|
|
base::flat_map<
|
|
|
|
uint64,
|
|
|
|
std::vector<base::weak_ptr<CustomEmojiLoader>>> _loaders;
|
|
|
|
|
2022-06-23 13:52:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void FillTestCustomEmoji(
|
|
|
|
not_null<Main::Session*> session,
|
|
|
|
TextWithEntities &text);
|
|
|
|
|
|
|
|
} // namespace Data
|