mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Support tg://premium_multigift links.
This commit is contained in:
parent
a30d0eccda
commit
a4d7309209
6 changed files with 30 additions and 10 deletions
|
@ -382,7 +382,8 @@ void GiftsBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
std::vector<not_null<UserData*>> users,
|
std::vector<not_null<UserData*>> users,
|
||||||
not_null<Api::PremiumGiftCodeOptions*> api) {
|
not_null<Api::PremiumGiftCodeOptions*> api,
|
||||||
|
const QString &ref) {
|
||||||
Expects(!users.empty());
|
Expects(!users.empty());
|
||||||
|
|
||||||
const auto boxWidth = st::boxWideWidth;
|
const auto boxWidth = st::boxWideWidth;
|
||||||
|
@ -591,7 +592,7 @@ void GiftsBox(
|
||||||
Settings::AddSummaryPremium(
|
Settings::AddSummaryPremium(
|
||||||
content,
|
content,
|
||||||
controller,
|
controller,
|
||||||
u"gift"_q,
|
ref,
|
||||||
std::move(buttonCallback));
|
std::move(buttonCallback));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -614,7 +615,7 @@ void GiftsBox(
|
||||||
auto raw = Settings::CreateSubscribeButton({
|
auto raw = Settings::CreateSubscribeButton({
|
||||||
controller,
|
controller,
|
||||||
box,
|
box,
|
||||||
[] { return u"gift"_q; },
|
[=] { return ref; },
|
||||||
rpl::combine(
|
rpl::combine(
|
||||||
state->buttonText.events(),
|
state->buttonText.events(),
|
||||||
state->confirmButtonBusy.value(),
|
state->confirmButtonBusy.value(),
|
||||||
|
@ -876,7 +877,7 @@ void GiftPremiumValidator::cancel() {
|
||||||
_requestId = 0;
|
_requestId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GiftPremiumValidator::showChoosePeerBox() {
|
void GiftPremiumValidator::showChoosePeerBox(const QString &ref) {
|
||||||
if (_manyGiftsLifetime) {
|
if (_manyGiftsLifetime) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -936,7 +937,7 @@ void GiftPremiumValidator::showChoosePeerBox() {
|
||||||
}) | ranges::to<std::vector<not_null<UserData*>>>();
|
}) | ranges::to<std::vector<not_null<UserData*>>>();
|
||||||
if (!users.empty()) {
|
if (!users.empty()) {
|
||||||
const auto giftBox = show->show(
|
const auto giftBox = show->show(
|
||||||
Box(GiftsBox, _controller, users, api));
|
Box(GiftsBox, _controller, users, api, ref));
|
||||||
giftBox->boxClosing(
|
giftBox->boxClosing(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
_manyGiftsLifetime.destroy();
|
_manyGiftsLifetime.destroy();
|
||||||
|
|
|
@ -34,7 +34,7 @@ public:
|
||||||
GiftPremiumValidator(not_null<Window::SessionController*> controller);
|
GiftPremiumValidator(not_null<Window::SessionController*> controller);
|
||||||
|
|
||||||
void showBox(not_null<UserData*> user);
|
void showBox(not_null<UserData*> user);
|
||||||
void showChoosePeerBox();
|
void showChoosePeerBox(const QString &ref);
|
||||||
void cancel();
|
void cancel();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -845,6 +845,21 @@ bool ResolvePremiumOffer(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ResolvePremiumMultigift(
|
||||||
|
Window::SessionController *controller,
|
||||||
|
const Match &match,
|
||||||
|
const QVariant &context) {
|
||||||
|
if (!controller) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const auto params = url_parse_params(
|
||||||
|
match->captured(1).mid(1),
|
||||||
|
qthelp::UrlParamNameTransform::ToLower);
|
||||||
|
controller->showGiftPremiumsBox(params.value(u"ref"_q, u"gift_url"_q));
|
||||||
|
controller->window().activate();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool ResolveLoginCode(
|
bool ResolveLoginCode(
|
||||||
Window::SessionController *controller,
|
Window::SessionController *controller,
|
||||||
const Match &match,
|
const Match &match,
|
||||||
|
@ -968,6 +983,10 @@ const std::vector<LocalUrlHandler> &LocalUrlHandlers() {
|
||||||
u"premium_offer/?(\\?.+)?(#|$)"_q,
|
u"premium_offer/?(\\?.+)?(#|$)"_q,
|
||||||
ResolvePremiumOffer,
|
ResolvePremiumOffer,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
u"^premium_multigift/?\\?(.+)(#|$)"_q,
|
||||||
|
ResolvePremiumMultigift,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
u"^login/?(\\?code=([0-9]+))(&|$)"_q,
|
u"^login/?(\\?code=([0-9]+))(&|$)"_q,
|
||||||
ResolveLoginCode
|
ResolveLoginCode
|
||||||
|
|
|
@ -427,7 +427,7 @@ void SetupPremium(
|
||||||
{ .icon = &st::menuIconGiftPremium }
|
{ .icon = &st::menuIconGiftPremium }
|
||||||
);
|
);
|
||||||
button->addClickHandler([=] {
|
button->addClickHandler([=] {
|
||||||
controller->showGiftPremiumsBox();
|
controller->showGiftPremiumsBox(u"gift"_q);
|
||||||
});
|
});
|
||||||
constexpr auto kNewExpiresAt = int(1735689600);
|
constexpr auto kNewExpiresAt = int(1735689600);
|
||||||
if (base::unixtime::now() < kNewExpiresAt) {
|
if (base::unixtime::now() < kNewExpiresAt) {
|
||||||
|
|
|
@ -1218,8 +1218,8 @@ void SessionController::showGiftPremiumBox(UserData *user) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionController::showGiftPremiumsBox() {
|
void SessionController::showGiftPremiumsBox(const QString &ref) {
|
||||||
_giftPremiumValidator.showChoosePeerBox();
|
_giftPremiumValidator.showChoosePeerBox(ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionController::init() {
|
void SessionController::init() {
|
||||||
|
|
|
@ -380,7 +380,7 @@ public:
|
||||||
|
|
||||||
void showEditPeerBox(PeerData *peer);
|
void showEditPeerBox(PeerData *peer);
|
||||||
void showGiftPremiumBox(UserData *user);
|
void showGiftPremiumBox(UserData *user);
|
||||||
void showGiftPremiumsBox();
|
void showGiftPremiumsBox(const QString &ref);
|
||||||
|
|
||||||
void enableGifPauseReason(GifPauseReason reason);
|
void enableGifPauseReason(GifPauseReason reason);
|
||||||
void disableGifPauseReason(GifPauseReason reason);
|
void disableGifPauseReason(GifPauseReason reason);
|
||||||
|
|
Loading…
Add table
Reference in a new issue