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