mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Add additional cloud premium stickers to fake-set.
This commit is contained in:
parent
068d3caef5
commit
9b92700c24
4 changed files with 74 additions and 10 deletions
|
@ -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
|
||||
|
|
|
@ -32,12 +32,17 @@ public:
|
|||
-> const std::vector<not_null<DocumentData*>> &;
|
||||
[[nodiscard]] rpl::producer<> stickersUpdated() const;
|
||||
|
||||
[[nodiscard]] auto cloudSet() const
|
||||
-> const std::vector<not_null<DocumentData*>> &;
|
||||
[[nodiscard]] rpl::producer<> cloudSetUpdated() const;
|
||||
|
||||
[[nodiscard]] int64 monthlyAmount() const;
|
||||
[[nodiscard]] QString monthlyCurrency() const;
|
||||
|
||||
private:
|
||||
void reloadPromo();
|
||||
void reloadStickers();
|
||||
void reloadCloudSet();
|
||||
|
||||
const not_null<Main::Session*> _session;
|
||||
MTP::Sender _api;
|
||||
|
@ -54,6 +59,11 @@ private:
|
|||
std::vector<not_null<DocumentData*>> _stickers;
|
||||
rpl::event_stream<> _stickersUpdated;
|
||||
|
||||
mtpRequestId _cloudSetRequestId = 0;
|
||||
uint64 _cloudSetHash = 0;
|
||||
std::vector<not_null<DocumentData*>> _cloudSet;
|
||||
rpl::event_stream<> _cloudSetUpdated;
|
||||
|
||||
int64 _monthlyAmount = 0;
|
||||
QString _monthlyCurrency;
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "media/clip/media_clip_reader.h"
|
||||
#include "apiwrap.h"
|
||||
#include "api/api_toggling_media.h" // Api::ToggleFavedSticker
|
||||
#include "api/api_premium.h"
|
||||
#include "styles/style_chat_helpers.h"
|
||||
#include "styles/style_window.h"
|
||||
#include "styles/style_menu_icons.h"
|
||||
|
@ -219,9 +220,10 @@ StickersListWidget::StickersListWidget(
|
|||
TabbedSelector::Action::Update
|
||||
) | rpl::start_to_stream(_choosingUpdated, lifetime());
|
||||
|
||||
Data::AmPremiumValue(
|
||||
&session()
|
||||
) | rpl::start_with_next([=](bool premium) {
|
||||
rpl::merge(
|
||||
Data::AmPremiumValue(&session()) | rpl::to_empty,
|
||||
session().api().premium().cloudSetUpdated()
|
||||
) | rpl::start_with_next([=] {
|
||||
refreshStickers();
|
||||
}, lifetime());
|
||||
}
|
||||
|
@ -1854,17 +1856,19 @@ void StickersListWidget::refreshMySets() {
|
|||
refreshRecentStickers(false);
|
||||
refreshMegagroupStickers(GroupStickersPlace::Visible);
|
||||
|
||||
_premiumsIndex = -1;
|
||||
for (auto i = 0, count = int(_mySets.size()); i != count; ++i) {
|
||||
if (_mySets[i].id == Data::Stickers::PremiumSetId) {
|
||||
_premiumsIndex = i;
|
||||
}
|
||||
}
|
||||
const auto i = ranges::find(
|
||||
_mySets,
|
||||
Data::Stickers::PremiumSetId,
|
||||
&Set::id);
|
||||
_premiumsIndex = (i != end(_mySets)) ? int(i - begin(_mySets)) : -1;
|
||||
|
||||
for (const auto setId : defaultSetsOrder()) {
|
||||
const auto externalLayout = false;
|
||||
appendSet(_mySets, setId, externalLayout, AppendSkip::Archived);
|
||||
}
|
||||
if (_premiumsIndex >= 0) {
|
||||
appendPremiumCloudSet();
|
||||
}
|
||||
|
||||
if (_premiumsIndex >= 0 && _mySets[_premiumsIndex].stickers.empty()) {
|
||||
_mySets.erase(_mySets.begin() + _premiumsIndex);
|
||||
|
@ -1876,6 +1880,16 @@ void StickersListWidget::refreshMySets() {
|
|||
takeHeavyData(_mySets, wasSets);
|
||||
}
|
||||
|
||||
void StickersListWidget::appendPremiumCloudSet() {
|
||||
Expects(_premiumsIndex >= 0 && _premiumsIndex < _mySets.size());
|
||||
|
||||
auto &set = _mySets[_premiumsIndex];
|
||||
for (const auto &document : session().api().premium().cloudSet()) {
|
||||
set.stickers.push_back(Sticker{ document });
|
||||
++set.count;
|
||||
}
|
||||
}
|
||||
|
||||
void StickersListWidget::refreshFeaturedSets() {
|
||||
auto wasFeaturedSetsCount = base::take(_featuredSetsCount);
|
||||
auto wereOfficial = base::take(_officialSets);
|
||||
|
@ -2018,8 +2032,8 @@ bool StickersListWidget::appendSet(
|
|||
const auto document = sticker.document;
|
||||
if (document->isPremiumSticker()) {
|
||||
to[_premiumsIndex].stickers.push_back(Sticker{ document });
|
||||
++to[_premiumsIndex].count;
|
||||
}
|
||||
++to[_premiumsIndex].count;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -221,6 +221,7 @@ private:
|
|||
};
|
||||
void refreshMegagroupStickers(GroupStickersPlace place);
|
||||
void refreshSettingsVisibility();
|
||||
void appendPremiumCloudSet();
|
||||
|
||||
void updateSelected();
|
||||
void setSelected(OverState newSelected);
|
||||
|
|
Loading…
Add table
Reference in a new issue