2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-05 00:46:08 +00:00

Add additional cloud premium stickers to fake-set.

This commit is contained in:
John Preston
2022-08-04 17:48:36 +03:00
parent 068d3caef5
commit 9b92700c24
4 changed files with 74 additions and 10 deletions

View File

@@ -27,6 +27,9 @@ Premium::Premium(not_null<ApiWrap*> api)
_session
) | rpl::start_with_next([=] {
reload();
if (_session->premium()) {
reloadCloudSet();
}
}, _session->lifetime());
});
}
@@ -54,6 +57,15 @@ rpl::producer<> Premium::stickersUpdated() const {
return _stickersUpdated.events();
}
auto Premium::cloudSet() const
-> const std::vector<not_null<DocumentData*>> & {
return _cloudSet;
}
rpl::producer<> Premium::cloudSetUpdated() const {
return _cloudSetUpdated.events();
}
int64 Premium::monthlyAmount() const {
return _monthlyAmount;
}
@@ -137,4 +149,31 @@ void Premium::reloadStickers() {
}).send();
}
void Premium::reloadCloudSet() {
if (_cloudSetRequestId) {
return;
}
_cloudSetRequestId = _api.request(MTPmessages_GetStickers(
MTP_string("\xf0\x9f\x93\x82\xe2\xad\x90\xef\xb8\x8f"),
MTP_long(_cloudSetHash)
)).done([=](const MTPmessages_Stickers &result) {
_cloudSetRequestId = 0;
result.match([&](const MTPDmessages_stickersNotModified &) {
}, [&](const MTPDmessages_stickers &data) {
_cloudSetHash = data.vhash().v;
const auto owner = &_session->data();
_cloudSet.clear();
for (const auto &sticker : data.vstickers().v) {
const auto document = owner->processDocument(sticker);
if (document->isPremiumSticker()) {
_cloudSet.push_back(document);
}
}
_cloudSetUpdated.fire({});
});
}).fail([=] {
_cloudSetRequestId = 0;
}).send();
}
} // namespace Api