mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 13:17:08 +02:00
Added ability to subscribe again via slug from subscriptions list.
This commit is contained in:
parent
f795d56b2a
commit
d69905feae
3 changed files with 38 additions and 16 deletions
|
@ -2523,6 +2523,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_credits_subscription_on_about" = "If you cancel now, you will still be able to access your subscription until {date}.";
|
"lng_credits_subscription_on_about" = "If you cancel now, you will still be able to access your subscription until {date}.";
|
||||||
|
|
||||||
"lng_credits_subscription_off_button" = "Renew Subscription";
|
"lng_credits_subscription_off_button" = "Renew Subscription";
|
||||||
|
"lng_credits_subscription_off_rejoin_button" = "Subscribe again";
|
||||||
"lng_credits_subscription_off_about" = "You have canceled your subscription.";
|
"lng_credits_subscription_off_about" = "You have canceled your subscription.";
|
||||||
"lng_credits_subscription_off_by_bot_about" = "{bot} has canceled your subscription.";
|
"lng_credits_subscription_off_by_bot_about" = "{bot} has canceled your subscription.";
|
||||||
|
|
||||||
|
|
|
@ -94,14 +94,14 @@ void ProcessCreditsPayment(
|
||||||
Ui::SendCreditsBox,
|
Ui::SendCreditsBox,
|
||||||
form,
|
form,
|
||||||
[=] {
|
[=] {
|
||||||
*unsuccessful = false;
|
*unsuccessful = false;
|
||||||
if (const auto widget = fireworks.data()) {
|
if (const auto widget = fireworks.data()) {
|
||||||
Ui::StartFireworks(widget);
|
Ui::StartFireworks(widget);
|
||||||
}
|
}
|
||||||
if (const auto onstack = maybeReturnToBot) {
|
if (const auto onstack = maybeReturnToBot) {
|
||||||
onstack(CheckoutResult::Paid);
|
onstack(CheckoutResult::Paid);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
box->boxClosing() | rpl::start_with_next([=] {
|
box->boxClosing() | rpl::start_with_next([=] {
|
||||||
crl::on_main([=] {
|
crl::on_main([=] {
|
||||||
if (*unsuccessful) {
|
if (*unsuccessful) {
|
||||||
|
|
|
@ -47,6 +47,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "payments/payments_checkout_process.h"
|
#include "payments/payments_checkout_process.h"
|
||||||
#include "payments/payments_form.h"
|
#include "payments/payments_form.h"
|
||||||
|
#include "payments/payments_non_panel_process.h"
|
||||||
#include "settings/settings_common_session.h"
|
#include "settings/settings_common_session.h"
|
||||||
#include "settings/settings_credits.h"
|
#include "settings/settings_credits.h"
|
||||||
#include "statistics/widgets/chart_header_widget.h"
|
#include "statistics/widgets/chart_header_widget.h"
|
||||||
|
@ -1376,15 +1377,23 @@ void ReceiptCreditsBox(
|
||||||
AddMiniStars(content, widget, stUser, st::boxWideWidth, 2);
|
AddMiniStars(content, widget, stUser, st::boxWideWidth, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto rejoinByApi = base::unixtime::serialize(s.until)
|
||||||
|
> base::unixtime::now();
|
||||||
|
const auto rejoinByInvite = !s.inviteHash.isEmpty();
|
||||||
|
const auto rejoinBySlug = !s.slug.isEmpty();
|
||||||
const auto toRenew = (s.cancelled || s.expired)
|
const auto toRenew = (s.cancelled || s.expired)
|
||||||
&& (!s.inviteHash.isEmpty()
|
&& (rejoinByApi || rejoinByInvite)
|
||||||
|| (base::unixtime::serialize(s.until) > base::unixtime::now()))
|
&& !s.cancelledByBot;
|
||||||
|
const auto toRejoin = (s.cancelled || s.expired)
|
||||||
|
&& rejoinBySlug
|
||||||
&& !s.cancelledByBot;
|
&& !s.cancelledByBot;
|
||||||
auto confirmText = rpl::conditional(
|
auto confirmText = rpl::conditional(
|
||||||
state->confirmButtonBusy.value(),
|
state->confirmButtonBusy.value(),
|
||||||
rpl::single(QString()),
|
rpl::single(QString()),
|
||||||
(toRenew
|
(toRenew
|
||||||
? tr::lng_credits_subscription_off_button()
|
? tr::lng_credits_subscription_off_button()
|
||||||
|
: toRejoin
|
||||||
|
? tr::lng_credits_subscription_off_rejoin_button()
|
||||||
: (canConvert || couldConvert || nonConvertible)
|
: (canConvert || couldConvert || nonConvertible)
|
||||||
? (e.savedToProfile
|
? (e.savedToProfile
|
||||||
? tr::lng_gift_display_on_page_hide()
|
? tr::lng_gift_display_on_page_hide()
|
||||||
|
@ -1432,6 +1441,19 @@ void ReceiptCreditsBox(
|
||||||
save,
|
save,
|
||||||
done);
|
done);
|
||||||
}
|
}
|
||||||
|
} else if (toRejoin) {
|
||||||
|
if (const auto window = weakWindow.get()) {
|
||||||
|
const auto finish = [=](Payments::CheckoutResult&&) {
|
||||||
|
ProcessReceivedSubscriptions(weak, session);
|
||||||
|
};
|
||||||
|
Payments::CheckoutProcess::Start(
|
||||||
|
&window->session(),
|
||||||
|
s.slug,
|
||||||
|
[](auto) {},
|
||||||
|
Payments::ProcessNonPanelPaymentFormFactory(
|
||||||
|
window,
|
||||||
|
finish));
|
||||||
|
}
|
||||||
} else if (toRenew && s.expired) {
|
} else if (toRenew && s.expired) {
|
||||||
Api::CheckChatInvite(controller, s.inviteHash, nullptr, [=] {
|
Api::CheckChatInvite(controller, s.inviteHash, nullptr, [=] {
|
||||||
ProcessReceivedSubscriptions(weak, session);
|
ProcessReceivedSubscriptions(weak, session);
|
||||||
|
@ -1450,7 +1472,10 @@ void ReceiptCreditsBox(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if ((toRenew || canConvert || couldConvert || nonConvertible) && peer) {
|
const auto willBusy = toRejoin
|
||||||
|
|| (peer
|
||||||
|
&& (toRenew || canConvert || couldConvert || nonConvertible));
|
||||||
|
if (willBusy) {
|
||||||
const auto close = Ui::CreateChild<Ui::IconButton>(
|
const auto close = Ui::CreateChild<Ui::IconButton>(
|
||||||
content,
|
content,
|
||||||
st::boxTitleClose);
|
st::boxTitleClose);
|
||||||
|
@ -1465,11 +1490,7 @@ void ReceiptCreditsBox(
|
||||||
|| state->convertButtonBusy.current()) {
|
|| state->convertButtonBusy.current()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (peer
|
if (willBusy) {
|
||||||
&& (toRenew
|
|
||||||
|| canConvert
|
|
||||||
|| couldConvert
|
|
||||||
|| nonConvertible)) {
|
|
||||||
state->confirmButtonBusy = true;
|
state->confirmButtonBusy = true;
|
||||||
send();
|
send();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue