mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +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<Window::SessionController*> controller,
|
||||
std::vector<not_null<UserData*>> users,
|
||||
not_null<Api::PremiumGiftCodeOptions*> api) {
|
||||
not_null<Api::PremiumGiftCodeOptions*> api,
|
||||
const QString &ref) {
|
||||
Expects(!users.empty());
|
||||
|
||||
const auto boxWidth = st::boxWideWidth;
|
||||
|
@ -591,7 +592,7 @@ void GiftsBox(
|
|||
Settings::AddSummaryPremium(
|
||||
content,
|
||||
controller,
|
||||
u"gift"_q,
|
||||
ref,
|
||||
std::move(buttonCallback));
|
||||
}
|
||||
|
||||
|
@ -614,7 +615,7 @@ void GiftsBox(
|
|||
auto raw = Settings::CreateSubscribeButton({
|
||||
controller,
|
||||
box,
|
||||
[] { return u"gift"_q; },
|
||||
[=] { return ref; },
|
||||
rpl::combine(
|
||||
state->buttonText.events(),
|
||||
state->confirmButtonBusy.value(),
|
||||
|
@ -876,7 +877,7 @@ void GiftPremiumValidator::cancel() {
|
|||
_requestId = 0;
|
||||
}
|
||||
|
||||
void GiftPremiumValidator::showChoosePeerBox() {
|
||||
void GiftPremiumValidator::showChoosePeerBox(const QString &ref) {
|
||||
if (_manyGiftsLifetime) {
|
||||
return;
|
||||
}
|
||||
|
@ -936,7 +937,7 @@ void GiftPremiumValidator::showChoosePeerBox() {
|
|||
}) | ranges::to<std::vector<not_null<UserData*>>>();
|
||||
if (!users.empty()) {
|
||||
const auto giftBox = show->show(
|
||||
Box(GiftsBox, _controller, users, api));
|
||||
Box(GiftsBox, _controller, users, api, ref));
|
||||
giftBox->boxClosing(
|
||||
) | rpl::start_with_next([=] {
|
||||
_manyGiftsLifetime.destroy();
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
GiftPremiumValidator(not_null<Window::SessionController*> controller);
|
||||
|
||||
void showBox(not_null<UserData*> user);
|
||||
void showChoosePeerBox();
|
||||
void showChoosePeerBox(const QString &ref);
|
||||
void cancel();
|
||||
|
||||
private:
|
||||
|
|
|
@ -845,6 +845,21 @@ bool ResolvePremiumOffer(
|
|||
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(
|
||||
Window::SessionController *controller,
|
||||
const Match &match,
|
||||
|
@ -968,6 +983,10 @@ const std::vector<LocalUrlHandler> &LocalUrlHandlers() {
|
|||
u"premium_offer/?(\\?.+)?(#|$)"_q,
|
||||
ResolvePremiumOffer,
|
||||
},
|
||||
{
|
||||
u"^premium_multigift/?\\?(.+)(#|$)"_q,
|
||||
ResolvePremiumMultigift,
|
||||
},
|
||||
{
|
||||
u"^login/?(\\?code=([0-9]+))(&|$)"_q,
|
||||
ResolveLoginCode
|
||||
|
|
|
@ -427,7 +427,7 @@ void SetupPremium(
|
|||
{ .icon = &st::menuIconGiftPremium }
|
||||
);
|
||||
button->addClickHandler([=] {
|
||||
controller->showGiftPremiumsBox();
|
||||
controller->showGiftPremiumsBox(u"gift"_q);
|
||||
});
|
||||
constexpr auto kNewExpiresAt = int(1735689600);
|
||||
if (base::unixtime::now() < kNewExpiresAt) {
|
||||
|
|
|
@ -1218,8 +1218,8 @@ void SessionController::showGiftPremiumBox(UserData *user) {
|
|||
}
|
||||
}
|
||||
|
||||
void SessionController::showGiftPremiumsBox() {
|
||||
_giftPremiumValidator.showChoosePeerBox();
|
||||
void SessionController::showGiftPremiumsBox(const QString &ref) {
|
||||
_giftPremiumValidator.showChoosePeerBox(ref);
|
||||
}
|
||||
|
||||
void SessionController::init() {
|
||||
|
|
|
@ -380,7 +380,7 @@ public:
|
|||
|
||||
void showEditPeerBox(PeerData *peer);
|
||||
void showGiftPremiumBox(UserData *user);
|
||||
void showGiftPremiumsBox();
|
||||
void showGiftPremiumsBox(const QString &ref);
|
||||
|
||||
void enableGifPauseReason(GifPauseReason reason);
|
||||
void disableGifPauseReason(GifPauseReason reason);
|
||||
|
|
Loading…
Add table
Reference in a new issue