mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Insert recent stickers as emoji for testing.
This commit is contained in:
parent
c796dd142b
commit
8ed101cbbf
1 changed files with 28 additions and 11 deletions
|
@ -13,7 +13,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_document.h"
|
#include "data/data_document.h"
|
||||||
#include "data/data_document_media.h"
|
#include "data/data_document_media.h"
|
||||||
#include "data/data_file_origin.h"
|
#include "data/data_file_origin.h"
|
||||||
#include "data/stickers/data_stickers_set.h"
|
|
||||||
#include "lottie/lottie_common.h"
|
#include "lottie/lottie_common.h"
|
||||||
#include "lottie/lottie_emoji.h"
|
#include "lottie/lottie_emoji.h"
|
||||||
#include "chat_helpers/stickers_lottie.h"
|
#include "chat_helpers/stickers_lottie.h"
|
||||||
|
@ -21,6 +20,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/ui_utility.h"
|
#include "ui/ui_utility.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
|
|
||||||
|
#include "data/stickers/data_stickers.h"
|
||||||
|
#include "data/stickers/data_stickers_set.h"
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
|
|
||||||
struct CustomEmojiId {
|
struct CustomEmojiId {
|
||||||
|
@ -537,25 +539,40 @@ Session &CustomEmojiManager::owner() const {
|
||||||
void FillTestCustomEmoji(
|
void FillTestCustomEmoji(
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
TextWithEntities &text) {
|
TextWithEntities &text) {
|
||||||
|
auto &sets = session->data().stickers().sets();
|
||||||
|
auto recentIt = sets.find(Data::Stickers::CloudRecentSetId);
|
||||||
const auto pack = &session->emojiStickersPack();
|
const auto pack = &session->emojiStickersPack();
|
||||||
const auto begin = text.text.constData(), end = begin + text.text.size();
|
const auto begin = text.text.constData(), end = begin + text.text.size();
|
||||||
for (auto ch = begin; ch != end;) {
|
for (auto ch = begin; ch != end;) {
|
||||||
auto length = 0;
|
auto length = 0;
|
||||||
if (const auto emoji = Ui::Emoji::Find(ch, end, &length)) {
|
if (const auto emoji = Ui::Emoji::Find(ch, end, &length)) {
|
||||||
|
auto replace = (DocumentData*)nullptr;
|
||||||
|
if (recentIt != sets.end()) {
|
||||||
|
for (const auto document : recentIt->second->stickers) {
|
||||||
|
if (const auto sticker = document->sticker()) {
|
||||||
|
if (Ui::Emoji::Find(sticker->alt) == emoji) {
|
||||||
|
replace = document;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (const auto found = pack->stickerForEmoji(emoji)) {
|
if (const auto found = pack->stickerForEmoji(emoji)) {
|
||||||
Assert(found.document->sticker() != nullptr);
|
Assert(found.document->sticker() != nullptr);
|
||||||
if (found.document->sticker()->set.id) {
|
if (!replace && found.document->sticker()->set.id) {
|
||||||
text.entities.push_back({
|
replace = found.document;
|
||||||
EntityType::CustomEmoji,
|
|
||||||
(ch - begin),
|
|
||||||
length,
|
|
||||||
SerializeCustomEmojiId({
|
|
||||||
found.document->sticker()->set,
|
|
||||||
found.document->id,
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (replace) {
|
||||||
|
text.entities.push_back({
|
||||||
|
EntityType::CustomEmoji,
|
||||||
|
(ch - begin),
|
||||||
|
length,
|
||||||
|
SerializeCustomEmojiId({
|
||||||
|
replace->sticker()->set,
|
||||||
|
replace->id,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
}
|
||||||
ch += length;
|
ch += length;
|
||||||
} else if (ch->isHighSurrogate()
|
} else if (ch->isHighSurrogate()
|
||||||
&& (ch + 1 != end)
|
&& (ch + 1 != end)
|
||||||
|
|
Loading…
Add table
Reference in a new issue