mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Minimal emoji sets support.
This commit is contained in:
parent
afc7b1da62
commit
ddd5021966
12 changed files with 182 additions and 49 deletions
|
@ -127,8 +127,12 @@ public:
|
||||||
|
|
||||||
void archiveStickers();
|
void archiveStickers();
|
||||||
|
|
||||||
bool isMasksSet() const {
|
[[nodiscard]] Data::StickersType setType() const {
|
||||||
return (_setFlags & SetFlag::Masks);
|
return (_setFlags & SetFlag::Emoji)
|
||||||
|
? Data::StickersType::Emoji
|
||||||
|
: (_setFlags & SetFlag::Masks)
|
||||||
|
? Data::StickersType::Masks
|
||||||
|
: Data::StickersType::Stickers;
|
||||||
}
|
}
|
||||||
|
|
||||||
~Inner();
|
~Inner();
|
||||||
|
@ -271,11 +275,14 @@ void StickerSetBox::prepare() {
|
||||||
|
|
||||||
_inner->setInstalled(
|
_inner->setInstalled(
|
||||||
) | rpl::start_with_next([=](uint64 setId) {
|
) | rpl::start_with_next([=](uint64 setId) {
|
||||||
if (_inner->isMasksSet()) {
|
if (_inner->setType() == Data::StickersType::Masks) {
|
||||||
Ui::Toast::Show(
|
Ui::Toast::Show(
|
||||||
Ui::BoxShow(this).toastParent(),
|
Ui::BoxShow(this).toastParent(),
|
||||||
tr::lng_masks_installed(tr::now));
|
tr::lng_masks_installed(tr::now));
|
||||||
} else {
|
} else if (_inner->setType() == Data::StickersType::Emoji) {
|
||||||
|
auto &stickers = _controller->session().data().stickers();
|
||||||
|
stickers.notifyEmojiSetInstalled(setId);
|
||||||
|
} else if (_inner->setType() == Data::StickersType::Stickers) {
|
||||||
auto &stickers = _controller->session().data().stickers();
|
auto &stickers = _controller->session().data().stickers();
|
||||||
stickers.notifyStickerSetInstalled(setId);
|
stickers.notifyStickerSetInstalled(setId);
|
||||||
}
|
}
|
||||||
|
@ -289,15 +296,18 @@ void StickerSetBox::prepare() {
|
||||||
|
|
||||||
_inner->setArchived(
|
_inner->setArchived(
|
||||||
) | rpl::start_with_next([=](uint64 setId) {
|
) | rpl::start_with_next([=](uint64 setId) {
|
||||||
const auto isMasks = _inner->isMasksSet();
|
const auto type = _inner->setType();
|
||||||
|
if (type == Data::StickersType::Emoji) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Ui::Toast::Show(
|
Ui::Toast::Show(
|
||||||
Ui::BoxShow(this).toastParent(),
|
Ui::BoxShow(this).toastParent(),
|
||||||
isMasks
|
(type == Data::StickersType::Masks)
|
||||||
? tr::lng_masks_has_been_archived(tr::now)
|
? tr::lng_masks_has_been_archived(tr::now)
|
||||||
: tr::lng_stickers_has_been_archived(tr::now));
|
: tr::lng_stickers_has_been_archived(tr::now));
|
||||||
|
|
||||||
auto &order = isMasks
|
auto &order = (type == Data::StickersType::Masks)
|
||||||
? _controller->session().data().stickers().maskSetsOrderRef()
|
? _controller->session().data().stickers().maskSetsOrderRef()
|
||||||
: _controller->session().data().stickers().setsOrderRef();
|
: _controller->session().data().stickers().setsOrderRef();
|
||||||
const auto index = order.indexOf(setId);
|
const auto index = order.indexOf(setId);
|
||||||
|
@ -305,7 +315,7 @@ void StickerSetBox::prepare() {
|
||||||
order.removeAt(index);
|
order.removeAt(index);
|
||||||
|
|
||||||
auto &local = _controller->session().local();
|
auto &local = _controller->session().local();
|
||||||
if (isMasks) {
|
if (type == Data::StickersType::Masks) {
|
||||||
local.writeInstalledMasks();
|
local.writeInstalledMasks();
|
||||||
local.writeArchivedMasks();
|
local.writeArchivedMasks();
|
||||||
} else {
|
} else {
|
||||||
|
@ -352,11 +362,11 @@ void StickerSetBox::updateTitleAndButtons() {
|
||||||
void StickerSetBox::updateButtons() {
|
void StickerSetBox::updateButtons() {
|
||||||
clearButtons();
|
clearButtons();
|
||||||
if (_inner->loaded()) {
|
if (_inner->loaded()) {
|
||||||
const auto isMasks = _inner->isMasksSet();
|
const auto type = _inner->setType();
|
||||||
if (_inner->notInstalled()) {
|
if (_inner->notInstalled()) {
|
||||||
auto addText = isMasks
|
auto addText = (type == Data::StickersType::Masks)
|
||||||
? tr::lng_stickers_add_masks()
|
? tr::lng_stickers_add_masks()
|
||||||
: tr::lng_stickers_add_pack();
|
: tr::lng_stickers_add_pack(); // #TODO emoji
|
||||||
addButton(std::move(addText), [=] { addStickers(); });
|
addButton(std::move(addText), [=] { addStickers(); });
|
||||||
addButton(tr::lng_cancel(), [=] { closeBox(); });
|
addButton(tr::lng_cancel(), [=] { closeBox(); });
|
||||||
|
|
||||||
|
@ -376,9 +386,9 @@ void StickerSetBox::updateButtons() {
|
||||||
top,
|
top,
|
||||||
st::popupMenuWithIcons);
|
st::popupMenuWithIcons);
|
||||||
(*menu)->addAction(
|
(*menu)->addAction(
|
||||||
(isMasks
|
((type == Data::StickersType::Masks)
|
||||||
? tr::lng_stickers_share_masks
|
? tr::lng_stickers_share_masks
|
||||||
: tr::lng_stickers_share_pack)(tr::now),
|
: tr::lng_stickers_share_pack)(tr::now), // #TODO emoji
|
||||||
share,
|
share,
|
||||||
&st::menuIconShare);
|
&st::menuIconShare);
|
||||||
(*menu)->popup(QCursor::pos());
|
(*menu)->popup(QCursor::pos());
|
||||||
|
@ -394,9 +404,9 @@ void StickerSetBox::updateButtons() {
|
||||||
Ui::BoxShow(this).toastParent(),
|
Ui::BoxShow(this).toastParent(),
|
||||||
tr::lng_stickers_copied(tr::now));
|
tr::lng_stickers_copied(tr::now));
|
||||||
};
|
};
|
||||||
auto shareText = isMasks
|
auto shareText = (type == Data::StickersType::Masks)
|
||||||
? tr::lng_stickers_share_masks()
|
? tr::lng_stickers_share_masks()
|
||||||
: tr::lng_stickers_share_pack();
|
: tr::lng_stickers_share_pack(); // #TODO emoji
|
||||||
addButton(std::move(shareText), std::move(share));
|
addButton(std::move(shareText), std::move(share));
|
||||||
addButton(tr::lng_cancel(), [=] { closeBox(); });
|
addButton(tr::lng_cancel(), [=] { closeBox(); });
|
||||||
|
|
||||||
|
@ -412,9 +422,9 @@ void StickerSetBox::updateButtons() {
|
||||||
top,
|
top,
|
||||||
st::popupMenuWithIcons);
|
st::popupMenuWithIcons);
|
||||||
(*menu)->addAction(
|
(*menu)->addAction(
|
||||||
isMasks
|
(type == Data::StickersType::Masks)
|
||||||
? tr::lng_masks_archive_pack(tr::now)
|
? tr::lng_masks_archive_pack(tr::now)
|
||||||
: tr::lng_stickers_archive_pack(tr::now),
|
: tr::lng_stickers_archive_pack(tr::now), // #TODO emoji
|
||||||
archive,
|
archive,
|
||||||
&st::menuIconArchive);
|
&st::menuIconArchive);
|
||||||
(*menu)->popup(QCursor::pos());
|
(*menu)->popup(QCursor::pos());
|
||||||
|
@ -599,15 +609,15 @@ void StickerSetBox::Inner::installDone(
|
||||||
const MTPmessages_StickerSetInstallResult &result) {
|
const MTPmessages_StickerSetInstallResult &result) {
|
||||||
auto &stickers = _controller->session().data().stickers();
|
auto &stickers = _controller->session().data().stickers();
|
||||||
auto &sets = stickers.setsRef();
|
auto &sets = stickers.setsRef();
|
||||||
const auto isMasks = isMasksSet();
|
const auto type = setType();
|
||||||
|
|
||||||
const bool wasArchived = (_setFlags & SetFlag::Archived);
|
const bool wasArchived = (_setFlags & SetFlag::Archived);
|
||||||
if (wasArchived) {
|
if (wasArchived && type != Data::StickersType::Emoji) {
|
||||||
const auto index = (isMasks
|
const auto index = ((type == Data::StickersType::Masks)
|
||||||
? stickers.archivedMaskSetsOrderRef()
|
? stickers.archivedMaskSetsOrderRef()
|
||||||
: stickers.archivedSetsOrderRef()).indexOf(_setId);
|
: stickers.archivedSetsOrderRef()).indexOf(_setId);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
(isMasks
|
((type == Data::StickersType::Masks)
|
||||||
? stickers.archivedMaskSetsOrderRef()
|
? stickers.archivedMaskSetsOrderRef()
|
||||||
: stickers.archivedSetsOrderRef()).removeAt(index);
|
: stickers.archivedSetsOrderRef()).removeAt(index);
|
||||||
}
|
}
|
||||||
|
@ -638,7 +648,9 @@ void StickerSetBox::Inner::installDone(
|
||||||
set->stickers = _pack;
|
set->stickers = _pack;
|
||||||
set->emoji = _emoji;
|
set->emoji = _emoji;
|
||||||
|
|
||||||
auto &order = isMasks
|
auto &order = (type == Data::StickersType::Emoji)
|
||||||
|
? stickers.emojiSetsOrderRef()
|
||||||
|
: (type == Data::StickersType::Masks)
|
||||||
? stickers.maskSetsOrderRef()
|
? stickers.maskSetsOrderRef()
|
||||||
: stickers.setsOrderRef();
|
: stickers.setsOrderRef();
|
||||||
const auto insertAtIndex = 0, currentIndex = int(order.indexOf(_setId));
|
const auto insertAtIndex = 0, currentIndex = int(order.indexOf(_setId));
|
||||||
|
@ -668,14 +680,16 @@ void StickerSetBox::Inner::installDone(
|
||||||
result.c_messages_stickerSetInstallResultArchive());
|
result.c_messages_stickerSetInstallResultArchive());
|
||||||
} else {
|
} else {
|
||||||
auto &storage = _controller->session().local();
|
auto &storage = _controller->session().local();
|
||||||
if (wasArchived) {
|
if (wasArchived && type != Data::StickersType::Emoji) {
|
||||||
if (isMasks) {
|
if (type == Data::StickersType::Masks) {
|
||||||
storage.writeArchivedMasks();
|
storage.writeArchivedMasks();
|
||||||
} else {
|
} else {
|
||||||
storage.writeArchivedStickers();
|
storage.writeArchivedStickers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isMasks) {
|
if (type == Data::StickersType::Emoji) {
|
||||||
|
storage.writeInstalledCustomEmoji();
|
||||||
|
} else if (type == Data::StickersType::Masks) {
|
||||||
storage.writeInstalledMasks();
|
storage.writeInstalledMasks();
|
||||||
} else {
|
} else {
|
||||||
storage.writeInstalledStickers();
|
storage.writeInstalledStickers();
|
||||||
|
@ -723,7 +737,9 @@ void StickerSetBox::Inner::mouseReleaseEvent(QMouseEvent *e) {
|
||||||
}
|
}
|
||||||
_previewTimer.cancel();
|
_previewTimer.cancel();
|
||||||
const auto index = stickerFromGlobalPos(e->globalPos());
|
const auto index = stickerFromGlobalPos(e->globalPos());
|
||||||
if (index < 0 || index >= _pack.size() || isMasksSet()) {
|
if (index < 0
|
||||||
|
|| index >= _pack.size()
|
||||||
|
|| setType() != Data::StickersType::Stickers) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
send(_pack[index], {});
|
send(_pack[index], {});
|
||||||
|
@ -786,7 +802,7 @@ void StickerSetBox::Inner::contextMenuEvent(QContextMenuEvent *e) {
|
||||||
|
|
||||||
void StickerSetBox::Inner::updateSelected() {
|
void StickerSetBox::Inner::updateSelected() {
|
||||||
auto selected = stickerFromGlobalPos(QCursor::pos());
|
auto selected = stickerFromGlobalPos(QCursor::pos());
|
||||||
setSelected(isMasksSet() ? -1 : selected);
|
setSelected(setType() != Data::StickersType::Stickers ? -1 : selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickerSetBox::Inner::setSelected(int selected) {
|
void StickerSetBox::Inner::setSelected(int selected) {
|
||||||
|
|
|
@ -1001,13 +1001,13 @@ void StickersBox::saveChanges() {
|
||||||
session().api().saveStickerSets(
|
session().api().saveStickerSets(
|
||||||
installed->getOrder(),
|
installed->getOrder(),
|
||||||
installed->getRemovedSets(),
|
installed->getRemovedSets(),
|
||||||
false);
|
Data::StickersType::Stickers);
|
||||||
}
|
}
|
||||||
if (masks) {
|
if (masks) {
|
||||||
session().api().saveStickerSets(
|
session().api().saveStickerSets(
|
||||||
masks->getOrder(),
|
masks->getOrder(),
|
||||||
masks->getRemovedSets(),
|
masks->getRemovedSets(),
|
||||||
true);
|
Data::StickersType::Masks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1024,7 +1024,7 @@ void EmojiListWidget::refreshCustom() {
|
||||||
auto searchFromIndex = 0;
|
auto searchFromIndex = 0;
|
||||||
auto old = base::take(_custom);
|
auto old = base::take(_custom);
|
||||||
const auto owner = &controller()->session().data();
|
const auto owner = &controller()->session().data();
|
||||||
const auto &order = owner->stickers().setsOrder();
|
const auto &order = owner->stickers().emojiSetsOrder();
|
||||||
const auto &sets = owner->stickers().sets();
|
const auto &sets = owner->stickers().sets();
|
||||||
for (const auto setId : order) {
|
for (const auto setId : order) {
|
||||||
auto it = sets.find(setId);
|
auto it = sets.find(setId);
|
||||||
|
@ -1158,8 +1158,8 @@ void EmojiListWidget::showEmojiSection(Section section) {
|
||||||
refreshRecent();
|
refreshRecent();
|
||||||
|
|
||||||
auto y = 0;
|
auto y = 0;
|
||||||
enumerateSections([&y, sectionForSearch = section](const SectionInfo &info) {
|
enumerateSections([&](const SectionInfo &info) {
|
||||||
if (static_cast<Section>(info.section) == sectionForSearch) {
|
if (static_cast<Section>(info.section) == section) {
|
||||||
y = info.top;
|
y = info.top;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1172,6 +1172,28 @@ void EmojiListWidget::showEmojiSection(Section section) {
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EmojiListWidget::showCustomSet(uint64 setId) {
|
||||||
|
clearSelection();
|
||||||
|
|
||||||
|
refreshCustom();
|
||||||
|
|
||||||
|
auto y = 0;
|
||||||
|
enumerateSections([&](const SectionInfo &info) {
|
||||||
|
if (info.section >= kEmojiSectionCount) {
|
||||||
|
if (_custom[info.section - kEmojiSectionCount].id == setId) {
|
||||||
|
y = info.top;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
scrollTo(y);
|
||||||
|
|
||||||
|
_lastMousePos = QCursor::pos();
|
||||||
|
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
tr::phrase<> EmojiCategoryTitle(int index) {
|
tr::phrase<> EmojiCategoryTitle(int index) {
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 1: return tr::lng_emoji_category1;
|
case 1: return tr::lng_emoji_category1;
|
||||||
|
|
|
@ -53,6 +53,8 @@ public:
|
||||||
void showEmojiSection(Section section);
|
void showEmojiSection(Section section);
|
||||||
[[nodiscard]] Section currentSection(int yOffset) const;
|
[[nodiscard]] Section currentSection(int yOffset) const;
|
||||||
|
|
||||||
|
void showCustomSet(uint64 setId);
|
||||||
|
|
||||||
// Ui::AbstractTooltipShower interface.
|
// Ui::AbstractTooltipShower interface.
|
||||||
QString tooltipText() const override;
|
QString tooltipText() const override;
|
||||||
QPoint tooltipPos() const override;
|
QPoint tooltipPos() const override;
|
||||||
|
|
|
@ -401,6 +401,15 @@ TabbedSelector::TabbedSelector(
|
||||||
refreshStickers();
|
refreshStickers();
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hasEmojiTab()) {
|
||||||
|
session().data().stickers().emojiSetInstalled(
|
||||||
|
) | rpl::start_with_next([=](uint64 setId) {
|
||||||
|
_tabsSlider->setActiveSection(indexByType(SelectorTab::Emoji));
|
||||||
|
emoji()->showCustomSet(setId);
|
||||||
|
_showRequests.fire({});
|
||||||
|
}, lifetime());
|
||||||
|
}
|
||||||
//setAttribute(Qt::WA_AcceptTouchEvents);
|
//setAttribute(Qt::WA_AcceptTouchEvents);
|
||||||
setAttribute(Qt::WA_OpaquePaintEvent, false);
|
setAttribute(Qt::WA_OpaquePaintEvent, false);
|
||||||
showAll();
|
showAll();
|
||||||
|
@ -772,6 +781,9 @@ void TabbedSelector::showStarted() {
|
||||||
if (hasMasksTab()) {
|
if (hasMasksTab()) {
|
||||||
session().api().updateMasks();
|
session().api().updateMasks();
|
||||||
}
|
}
|
||||||
|
if (hasEmojiTab()) {
|
||||||
|
session().api().updateCustomEmoji();
|
||||||
|
}
|
||||||
currentTab()->widget()->refreshRecent();
|
currentTab()->widget()->refreshRecent();
|
||||||
currentTab()->widget()->preloadImages();
|
currentTab()->widget()->preloadImages();
|
||||||
_a_slide.stop();
|
_a_slide.stop();
|
||||||
|
|
|
@ -82,7 +82,7 @@ bool ShowStickerSet(
|
||||||
Core::App().hideMediaView();
|
Core::App().hideMediaView();
|
||||||
controller->show(Box<StickerSetBox>(
|
controller->show(Box<StickerSetBox>(
|
||||||
controller,
|
controller,
|
||||||
StickerSetIdentifier{ .shortName = match->captured(1) }));
|
StickerSetIdentifier{ .shortName = match->captured(2) }));
|
||||||
controller->window().activate();
|
controller->window().activate();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -781,7 +781,7 @@ const std::vector<LocalUrlHandler> &LocalUrlHandlers() {
|
||||||
JoinGroupByHash
|
JoinGroupByHash
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
qsl("^addstickers/?\\?set=([a-zA-Z0-9\\.\\_]+)(&|$)"),
|
qsl("^(addstickers|addemoji)/?\\?set=([a-zA-Z0-9\\.\\_]+)(&|$)"),
|
||||||
ShowStickerSet
|
ShowStickerSet
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -885,8 +885,8 @@ QString TryConvertUrlToLocal(QString url) {
|
||||||
return qsl("tg://resolve?phone=") + phoneMatch->captured(1) + (params.isEmpty() ? QString() : '&' + params);
|
return qsl("tg://resolve?phone=") + phoneMatch->captured(1) + (params.isEmpty() ? QString() : '&' + params);
|
||||||
} else if (auto joinChatMatch = regex_match(qsl("^(joinchat/|\\+|\\%20)([a-zA-Z0-9\\.\\_\\-]+)(\\?|$)"), query, matchOptions)) {
|
} else if (auto joinChatMatch = regex_match(qsl("^(joinchat/|\\+|\\%20)([a-zA-Z0-9\\.\\_\\-]+)(\\?|$)"), query, matchOptions)) {
|
||||||
return qsl("tg://join?invite=") + url_encode(joinChatMatch->captured(2));
|
return qsl("tg://join?invite=") + url_encode(joinChatMatch->captured(2));
|
||||||
} else if (auto stickerSetMatch = regex_match(qsl("^addstickers/([a-zA-Z0-9\\.\\_]+)(\\?|$)"), query, matchOptions)) {
|
} else if (auto stickerSetMatch = regex_match(qsl("^(addstickers|addemoji)/([a-zA-Z0-9\\.\\_]+)(\\?|$)"), query, matchOptions)) {
|
||||||
return qsl("tg://addstickers?set=") + url_encode(stickerSetMatch->captured(1));
|
return qsl("tg://") + stickerSetMatch->captured(1) + "?set=" + url_encode(stickerSetMatch->captured(2));
|
||||||
} else if (auto themeMatch = regex_match(qsl("^addtheme/([a-zA-Z0-9\\.\\_]+)(\\?|$)"), query, matchOptions)) {
|
} else if (auto themeMatch = regex_match(qsl("^addtheme/([a-zA-Z0-9\\.\\_]+)(\\?|$)"), query, matchOptions)) {
|
||||||
return qsl("tg://addtheme?slug=") + url_encode(themeMatch->captured(1));
|
return qsl("tg://addtheme?slug=") + url_encode(themeMatch->captured(1));
|
||||||
} else if (auto languageMatch = regex_match(qsl("^setlanguage/([a-zA-Z0-9\\.\\_\\-]+)(\\?|$)"), query, matchOptions)) {
|
} else if (auto languageMatch = regex_match(qsl("^setlanguage/([a-zA-Z0-9\\.\\_\\-]+)(\\?|$)"), query, matchOptions)) {
|
||||||
|
|
|
@ -178,6 +178,14 @@ rpl::producer<uint64> Stickers::stickerSetInstalled() const {
|
||||||
return _stickerSetInstalled.events();
|
return _stickerSetInstalled.events();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Stickers::notifyEmojiSetInstalled(uint64 setId) {
|
||||||
|
_emojiSetInstalled.fire(std::move(setId));
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<uint64> Stickers::emojiSetInstalled() const {
|
||||||
|
return _emojiSetInstalled.events();
|
||||||
|
}
|
||||||
|
|
||||||
void Stickers::incrementSticker(not_null<DocumentData*> document) {
|
void Stickers::incrementSticker(not_null<DocumentData*> document) {
|
||||||
if (!document->sticker() || !document->sticker()->set) {
|
if (!document->sticker() || !document->sticker()->set) {
|
||||||
return;
|
return;
|
||||||
|
@ -662,28 +670,42 @@ void Stickers::setFaved(
|
||||||
void Stickers::setsReceived(
|
void Stickers::setsReceived(
|
||||||
const QVector<MTPStickerSet> &data,
|
const QVector<MTPStickerSet> &data,
|
||||||
uint64 hash) {
|
uint64 hash) {
|
||||||
setsOrMasksReceived(data, hash, false);
|
somethingReceived(data, hash, StickersType::Stickers);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stickers::masksReceived(
|
void Stickers::masksReceived(
|
||||||
const QVector<MTPStickerSet> &data,
|
const QVector<MTPStickerSet> &data,
|
||||||
uint64 hash) {
|
uint64 hash) {
|
||||||
setsOrMasksReceived(data, hash, true);
|
somethingReceived(data, hash, StickersType::Masks);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stickers::setsOrMasksReceived(
|
void Stickers::emojiReceived(
|
||||||
|
const QVector<MTPStickerSet> &data,
|
||||||
|
uint64 hash) {
|
||||||
|
somethingReceived(data, hash, StickersType::Emoji);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Stickers::somethingReceived(
|
||||||
const QVector<MTPStickerSet> &data,
|
const QVector<MTPStickerSet> &data,
|
||||||
uint64 hash,
|
uint64 hash,
|
||||||
bool masks) {
|
StickersType type) {
|
||||||
auto &setsOrder = masks ? maskSetsOrderRef() : setsOrderRef();
|
auto &setsOrder = (type == StickersType::Emoji)
|
||||||
|
? emojiSetsOrderRef()
|
||||||
|
: (type == StickersType::Masks)
|
||||||
|
? maskSetsOrderRef()
|
||||||
|
: setsOrderRef();
|
||||||
setsOrder.clear();
|
setsOrder.clear();
|
||||||
|
|
||||||
auto &sets = setsRef();
|
auto &sets = setsRef();
|
||||||
QMap<uint64, uint64> setsToRequest;
|
QMap<uint64, uint64> setsToRequest;
|
||||||
for (auto &[id, set] : sets) {
|
for (auto &[id, set] : sets) {
|
||||||
const auto archived = !!(set->flags & SetFlag::Archived);
|
const auto archived = !!(set->flags & SetFlag::Archived);
|
||||||
const auto maskset = !!(set->flags & SetFlag::Masks);
|
const auto setType = !!(set->flags & SetFlag::Emoji)
|
||||||
if (!archived && (masks == maskset)) {
|
? StickersType::Emoji
|
||||||
|
: !!(set->flags & SetFlag::Masks)
|
||||||
|
? StickersType::Masks
|
||||||
|
: StickersType::Stickers;
|
||||||
|
if (!archived && (type == setType)) {
|
||||||
// Mark for removing.
|
// Mark for removing.
|
||||||
set->flags &= ~SetFlag::Installed;
|
set->flags &= ~SetFlag::Installed;
|
||||||
set->installDate = 0;
|
set->installDate = 0;
|
||||||
|
@ -736,7 +758,9 @@ void Stickers::setsOrMasksReceived(
|
||||||
api.requestStickerSets();
|
api.requestStickerSets();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (masks) {
|
if (type == StickersType::Emoji) {
|
||||||
|
session().local().writeInstalledCustomEmoji();
|
||||||
|
} else if (type == StickersType::Masks) {
|
||||||
session().local().writeInstalledMasks();
|
session().local().writeInstalledMasks();
|
||||||
} else {
|
} else {
|
||||||
session().local().writeInstalledStickers();
|
session().local().writeInstalledStickers();
|
||||||
|
@ -745,12 +769,18 @@ void Stickers::setsOrMasksReceived(
|
||||||
session().saveSettings();
|
session().saveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto counted = masks
|
const auto counted = (type == StickersType::Emoji)
|
||||||
|
? Api::CountCustomEmojiHash(&session())
|
||||||
|
: (type == StickersType::Masks)
|
||||||
? Api::CountMasksHash(&session())
|
? Api::CountMasksHash(&session())
|
||||||
: Api::CountStickersHash(&session());
|
: Api::CountStickersHash(&session());
|
||||||
if (counted != hash) {
|
if (counted != hash) {
|
||||||
LOG(("API Error: received %1 hash %2 while counted hash is %3"
|
LOG(("API Error: received %1 hash %2 while counted hash is %3"
|
||||||
).arg(masks ? "masks" : "stickers"
|
).arg((type == StickersType::Emoji)
|
||||||
|
? "custom-emoji"
|
||||||
|
: (type == StickersType::Masks)
|
||||||
|
? "masks"
|
||||||
|
: "stickers"
|
||||||
).arg(hash
|
).arg(hash
|
||||||
).arg(counted));
|
).arg(counted));
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,8 @@ public:
|
||||||
[[nodiscard]] rpl::producer<> savedGifsUpdated() const;
|
[[nodiscard]] rpl::producer<> savedGifsUpdated() const;
|
||||||
void notifyStickerSetInstalled(uint64 setId);
|
void notifyStickerSetInstalled(uint64 setId);
|
||||||
[[nodiscard]] rpl::producer<uint64> stickerSetInstalled() const;
|
[[nodiscard]] rpl::producer<uint64> stickerSetInstalled() const;
|
||||||
|
void notifyEmojiSetInstalled(uint64 setId);
|
||||||
|
[[nodiscard]] rpl::producer<uint64> emojiSetInstalled() const;
|
||||||
|
|
||||||
void incrementSticker(not_null<DocumentData*> document);
|
void incrementSticker(not_null<DocumentData*> document);
|
||||||
|
|
||||||
|
@ -263,7 +265,7 @@ private:
|
||||||
StickersPack &&pack,
|
StickersPack &&pack,
|
||||||
const std::vector<TimeId> &&dates,
|
const std::vector<TimeId> &&dates,
|
||||||
const QVector<MTPStickerPack> &packs);
|
const QVector<MTPStickerPack> &packs);
|
||||||
void setsOrMasksOrEmojiReceived(
|
void somethingReceived(
|
||||||
const QVector<MTPStickerSet> &data,
|
const QVector<MTPStickerSet> &data,
|
||||||
uint64 hash,
|
uint64 hash,
|
||||||
StickersType type);
|
StickersType type);
|
||||||
|
@ -273,6 +275,7 @@ private:
|
||||||
rpl::event_stream<Recent> _recentUpdated;
|
rpl::event_stream<Recent> _recentUpdated;
|
||||||
rpl::event_stream<> _savedGifsUpdated;
|
rpl::event_stream<> _savedGifsUpdated;
|
||||||
rpl::event_stream<uint64> _stickerSetInstalled;
|
rpl::event_stream<uint64> _stickerSetInstalled;
|
||||||
|
rpl::event_stream<uint64> _emojiSetInstalled;
|
||||||
crl::time _lastUpdate = 0;
|
crl::time _lastUpdate = 0;
|
||||||
crl::time _lastRecentUpdate = 0;
|
crl::time _lastRecentUpdate = 0;
|
||||||
crl::time _lastFavedUpdate = 0;
|
crl::time _lastFavedUpdate = 0;
|
||||||
|
|
|
@ -155,6 +155,7 @@ Session::Session(
|
||||||
// So they can't be called during Main::Session construction.
|
// So they can't be called during Main::Session construction.
|
||||||
local().readInstalledStickers();
|
local().readInstalledStickers();
|
||||||
local().readInstalledMasks();
|
local().readInstalledMasks();
|
||||||
|
local().readInstalledCustomEmoji();
|
||||||
local().readFeaturedStickers();
|
local().readFeaturedStickers();
|
||||||
local().readRecentStickers();
|
local().readRecentStickers();
|
||||||
local().readRecentMasks();
|
local().readRecentMasks();
|
||||||
|
|
|
@ -144,8 +144,7 @@ DocumentData *Document::readFromStreamHelper(
|
||||||
MTP_string(alt),
|
MTP_string(alt),
|
||||||
MTP_inputStickerSetID(
|
MTP_inputStickerSetID(
|
||||||
MTP_long(info->setId),
|
MTP_long(info->setId),
|
||||||
MTP_long(info->accessHash)),
|
MTP_long(info->accessHash))));
|
||||||
MTPMaskCoords()));
|
|
||||||
} break;
|
} break;
|
||||||
case StickerSetTypeEmpty:
|
case StickerSetTypeEmpty:
|
||||||
default: {
|
default: {
|
||||||
|
|
|
@ -84,6 +84,7 @@ enum { // Local Storage Keys
|
||||||
lskBackgroundOld = 0x14, // no data
|
lskBackgroundOld = 0x14, // no data
|
||||||
lskSelfSerialized = 0x15, // serialized self
|
lskSelfSerialized = 0x15, // serialized self
|
||||||
lskMasksKeys = 0x16, // no data
|
lskMasksKeys = 0x16, // no data
|
||||||
|
lskCustomEmojiKeys = 0x17, // no data
|
||||||
};
|
};
|
||||||
|
|
||||||
auto EmptyMessageDraftSources()
|
auto EmptyMessageDraftSources()
|
||||||
|
@ -203,6 +204,9 @@ base::flat_set<QString> Account::collectGoodNames() const {
|
||||||
_installedMasksKey,
|
_installedMasksKey,
|
||||||
_recentMasksKey,
|
_recentMasksKey,
|
||||||
_archivedMasksKey,
|
_archivedMasksKey,
|
||||||
|
_installedCustomEmojiKey,
|
||||||
|
_recentCustomEmojiKey,
|
||||||
|
_archivedCustomEmojiKey,
|
||||||
};
|
};
|
||||||
auto result = base::flat_set<QString>{
|
auto result = base::flat_set<QString>{
|
||||||
"map0",
|
"map0",
|
||||||
|
@ -284,6 +288,7 @@ Account::ReadMapResult Account::readMapWith(
|
||||||
quint64 recentStickersKeyOld = 0;
|
quint64 recentStickersKeyOld = 0;
|
||||||
quint64 installedStickersKey = 0, featuredStickersKey = 0, recentStickersKey = 0, favedStickersKey = 0, archivedStickersKey = 0;
|
quint64 installedStickersKey = 0, featuredStickersKey = 0, recentStickersKey = 0, favedStickersKey = 0, archivedStickersKey = 0;
|
||||||
quint64 installedMasksKey = 0, recentMasksKey = 0, archivedMasksKey = 0;
|
quint64 installedMasksKey = 0, recentMasksKey = 0, archivedMasksKey = 0;
|
||||||
|
quint64 installedCustomEmojiKey = 0, recentCustomEmojiKey = 0, archivedCustomEmojiKey = 0;
|
||||||
quint64 savedGifsKey = 0;
|
quint64 savedGifsKey = 0;
|
||||||
quint64 legacyBackgroundKeyDay = 0, legacyBackgroundKeyNight = 0;
|
quint64 legacyBackgroundKeyDay = 0, legacyBackgroundKeyNight = 0;
|
||||||
quint64 userSettingsKey = 0, recentHashtagsAndBotsKey = 0, exportSettingsKey = 0;
|
quint64 userSettingsKey = 0, recentHashtagsAndBotsKey = 0, exportSettingsKey = 0;
|
||||||
|
@ -386,6 +391,12 @@ Account::ReadMapResult Account::readMapWith(
|
||||||
>> recentMasksKey
|
>> recentMasksKey
|
||||||
>> archivedMasksKey;
|
>> archivedMasksKey;
|
||||||
} break;
|
} break;
|
||||||
|
case lskCustomEmojiKeys: {
|
||||||
|
map.stream
|
||||||
|
>> installedCustomEmojiKey
|
||||||
|
>> recentCustomEmojiKey
|
||||||
|
>> archivedCustomEmojiKey;
|
||||||
|
} break;
|
||||||
default:
|
default:
|
||||||
LOG(("App Error: unknown key type in encrypted map: %1").arg(keyType));
|
LOG(("App Error: unknown key type in encrypted map: %1").arg(keyType));
|
||||||
return ReadMapResult::Failed;
|
return ReadMapResult::Failed;
|
||||||
|
@ -413,6 +424,9 @@ Account::ReadMapResult Account::readMapWith(
|
||||||
_installedMasksKey = installedMasksKey;
|
_installedMasksKey = installedMasksKey;
|
||||||
_recentMasksKey = recentMasksKey;
|
_recentMasksKey = recentMasksKey;
|
||||||
_archivedMasksKey = archivedMasksKey;
|
_archivedMasksKey = archivedMasksKey;
|
||||||
|
_installedCustomEmojiKey = installedCustomEmojiKey;
|
||||||
|
_recentCustomEmojiKey = recentCustomEmojiKey;
|
||||||
|
_archivedCustomEmojiKey = archivedCustomEmojiKey;
|
||||||
_legacyBackgroundKeyDay = legacyBackgroundKeyDay;
|
_legacyBackgroundKeyDay = legacyBackgroundKeyDay;
|
||||||
_legacyBackgroundKeyNight = legacyBackgroundKeyNight;
|
_legacyBackgroundKeyNight = legacyBackgroundKeyNight;
|
||||||
_settingsKey = userSettingsKey;
|
_settingsKey = userSettingsKey;
|
||||||
|
@ -520,6 +534,9 @@ void Account::writeMap() {
|
||||||
if (_installedMasksKey || _recentMasksKey || _archivedMasksKey) {
|
if (_installedMasksKey || _recentMasksKey || _archivedMasksKey) {
|
||||||
mapSize += sizeof(quint32) + 3 * sizeof(quint64);
|
mapSize += sizeof(quint32) + 3 * sizeof(quint64);
|
||||||
}
|
}
|
||||||
|
if (_installedCustomEmojiKey || _recentCustomEmojiKey || _archivedCustomEmojiKey) {
|
||||||
|
mapSize += sizeof(quint32) + 3 * sizeof(quint64);
|
||||||
|
}
|
||||||
|
|
||||||
EncryptedDescriptor mapData(mapSize);
|
EncryptedDescriptor mapData(mapSize);
|
||||||
if (!self.isEmpty()) {
|
if (!self.isEmpty()) {
|
||||||
|
@ -572,6 +589,13 @@ void Account::writeMap() {
|
||||||
<< quint64(_recentMasksKey)
|
<< quint64(_recentMasksKey)
|
||||||
<< quint64(_archivedMasksKey);
|
<< quint64(_archivedMasksKey);
|
||||||
}
|
}
|
||||||
|
if (_installedCustomEmojiKey || _recentCustomEmojiKey || _archivedCustomEmojiKey) {
|
||||||
|
mapData.stream << quint32(lskCustomEmojiKeys);
|
||||||
|
mapData.stream
|
||||||
|
<< quint64(_installedCustomEmojiKey)
|
||||||
|
<< quint64(_recentCustomEmojiKey)
|
||||||
|
<< quint64(_archivedCustomEmojiKey);
|
||||||
|
}
|
||||||
map.writeEncrypted(mapData, _localKey);
|
map.writeEncrypted(mapData, _localKey);
|
||||||
|
|
||||||
_mapChanged = false;
|
_mapChanged = false;
|
||||||
|
@ -593,6 +617,9 @@ void Account::reset() {
|
||||||
_installedMasksKey = 0;
|
_installedMasksKey = 0;
|
||||||
_recentMasksKey = 0;
|
_recentMasksKey = 0;
|
||||||
_archivedMasksKey = 0;
|
_archivedMasksKey = 0;
|
||||||
|
_installedCustomEmojiKey = 0;
|
||||||
|
_recentCustomEmojiKey = 0;
|
||||||
|
_archivedCustomEmojiKey = 0;
|
||||||
_legacyBackgroundKeyDay = _legacyBackgroundKeyNight = 0;
|
_legacyBackgroundKeyDay = _legacyBackgroundKeyNight = 0;
|
||||||
_settingsKey = _recentHashtagsAndBotsKey = _exportSettingsKey = 0;
|
_settingsKey = _recentHashtagsAndBotsKey = _exportSettingsKey = 0;
|
||||||
_oldMapVersion = 0;
|
_oldMapVersion = 0;
|
||||||
|
@ -2091,6 +2118,17 @@ void Account::writeRecentMasks() {
|
||||||
}, Data::StickersSetsOrder());
|
}, Data::StickersSetsOrder());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Account::writeInstalledCustomEmoji() {
|
||||||
|
using SetFlag = Data::StickersSetFlag;
|
||||||
|
|
||||||
|
writeStickerSets(_installedCustomEmojiKey, [](const Data::StickersSet &set) {
|
||||||
|
if (!(set.flags & SetFlag::Emoji) || set.stickers.isEmpty()) {
|
||||||
|
return StickerSetCheckResult::Skip;
|
||||||
|
}
|
||||||
|
return StickerSetCheckResult::Write;
|
||||||
|
}, _owner->session().data().stickers().emojiSetsOrder());
|
||||||
|
}
|
||||||
|
|
||||||
void Account::importOldRecentStickers() {
|
void Account::importOldRecentStickers() {
|
||||||
using SetFlag = Data::StickersSetFlag;
|
using SetFlag = Data::StickersSetFlag;
|
||||||
|
|
||||||
|
@ -2283,6 +2321,13 @@ void Account::readInstalledMasks() {
|
||||||
Data::StickersSetFlag::Installed);
|
Data::StickersSetFlag::Installed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Account::readInstalledCustomEmoji() {
|
||||||
|
readStickerSets(
|
||||||
|
_installedCustomEmojiKey,
|
||||||
|
&_owner->session().data().stickers().emojiSetsOrderRef(),
|
||||||
|
Data::StickersSetFlag::Installed);
|
||||||
|
}
|
||||||
|
|
||||||
void Account::writeSavedGifs() {
|
void Account::writeSavedGifs() {
|
||||||
const auto &saved = _owner->session().data().stickers().savedGifs();
|
const auto &saved = _owner->session().data().stickers().savedGifs();
|
||||||
if (saved.isEmpty()) {
|
if (saved.isEmpty()) {
|
||||||
|
|
|
@ -286,6 +286,9 @@ private:
|
||||||
FileKey _exportSettingsKey = 0;
|
FileKey _exportSettingsKey = 0;
|
||||||
FileKey _installedMasksKey = 0;
|
FileKey _installedMasksKey = 0;
|
||||||
FileKey _recentMasksKey = 0;
|
FileKey _recentMasksKey = 0;
|
||||||
|
FileKey _installedCustomEmojiKey = 0;
|
||||||
|
FileKey _recentCustomEmojiKey = 0;
|
||||||
|
FileKey _archivedCustomEmojiKey = 0;
|
||||||
|
|
||||||
qint64 _cacheTotalSizeLimit = 0;
|
qint64 _cacheTotalSizeLimit = 0;
|
||||||
qint64 _cacheBigFileTotalSizeLimit = 0;
|
qint64 _cacheBigFileTotalSizeLimit = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue