2019-08-01 15:13:02 +01: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
|
|
|
|
|
|
|
|
namespace Main {
|
|
|
|
class Session;
|
|
|
|
} // namespace Main
|
|
|
|
|
|
|
|
class HistoryItem;
|
|
|
|
class DocumentData;
|
|
|
|
|
|
|
|
namespace Stickers {
|
|
|
|
|
|
|
|
class EmojiPack final {
|
|
|
|
public:
|
|
|
|
explicit EmojiPack(not_null<Main::Session*> session);
|
|
|
|
|
2019-08-01 22:14:19 +01:00
|
|
|
bool add(not_null<HistoryItem*> item, const QString &text);
|
|
|
|
bool remove(not_null<const HistoryItem*> item);
|
|
|
|
|
2019-08-01 15:13:02 +01:00
|
|
|
[[nodiscard]] DocumentData *stickerForEmoji(not_null<HistoryItem*> item);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void refresh();
|
|
|
|
void refreshDelayed();
|
2019-08-01 22:14:19 +01:00
|
|
|
void applySet(const MTPDmessages_stickerSet &data);
|
|
|
|
void applyPack(
|
|
|
|
const MTPDstickerPack &data,
|
|
|
|
const base::flat_map<uint64, not_null<DocumentData*>> &map);
|
|
|
|
base::flat_map<uint64, not_null<DocumentData*>> collectStickers(
|
|
|
|
const QVector<MTPDocument> &list) const;
|
|
|
|
void refreshItems(EmojiPtr emoji);
|
2019-08-01 15:13:02 +01:00
|
|
|
|
|
|
|
not_null<Main::Session*> _session;
|
|
|
|
base::flat_set<not_null<HistoryItem*>> _notLoaded;
|
|
|
|
base::flat_map<EmojiPtr, not_null<DocumentData*>> _map;
|
2019-08-01 22:14:19 +01:00
|
|
|
base::flat_map<EmojiPtr, base::flat_set<not_null<HistoryItem*>>> _items;
|
2019-08-01 15:13:02 +01:00
|
|
|
mtpRequestId _requestId = 0;
|
|
|
|
|
|
|
|
rpl::lifetime _lifetime;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Stickers
|