mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-17 22:57:11 +02:00
Add toasts about giveaway/gift start.
This commit is contained in:
parent
f7ad91e80c
commit
8a804fcfad
3 changed files with 50 additions and 6 deletions
|
@ -2119,6 +2119,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_giveaway_channels_confirm_title" = "Channel is Private";
|
||||
"lng_giveaway_channels_confirm_about" = "Are you sure you want to add a private channel? Users won't be able to join it without an invite link.";
|
||||
|
||||
"lng_giveaway_created_title" = "Giveaway created";
|
||||
"lng_giveaway_created_body" = "Check your channels' {link} to see how this giveaway boosted your channel.";
|
||||
"lng_giveaway_awarded_title" = "Premium subscriptions gifted";
|
||||
"lng_giveaway_awarded_body" = "Check your channels' {link} to see how gifts boosted your channel.";
|
||||
"lng_giveaway_created_link" = "Statistics";
|
||||
|
||||
"lng_prize_title" = "Congratulations!";
|
||||
"lng_prize_about" = "You won a prize in a giveaway organized by {channel}.";
|
||||
"lng_prize_duration" = "Your prize is a **Telegram Premium** subscription {duration}.";
|
||||
|
|
|
@ -15,7 +15,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "info/boosts/giveaway/giveaway_list_controllers.h"
|
||||
#include "info/boosts/giveaway/giveaway_type_row.h"
|
||||
#include "info/boosts/giveaway/select_countries_box.h"
|
||||
#include "info/boosts/info_boosts_widget.h"
|
||||
#include "info/info_controller.h"
|
||||
#include "info/info_memento.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "payments/payments_checkout_process.h" // Payments::CheckoutProcess
|
||||
#include "payments/payments_form.h" // Payments::InvoicePremiumGiftCode
|
||||
|
@ -40,6 +42,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
namespace {
|
||||
|
||||
constexpr auto kDoneTooltipDuration = 5 * crl::time(1000);
|
||||
|
||||
[[nodiscard]] QDateTime ThreeDaysAfterToday() {
|
||||
auto dateNow = QDateTime::currentDateTime();
|
||||
dateNow = dateNow.addDays(3);
|
||||
|
@ -71,6 +75,8 @@ void CreateGiveawayBox(
|
|||
not_null<PeerData*> peer) {
|
||||
box->setWidth(st::boxWideWidth);
|
||||
|
||||
const auto weakWindow = base::make_weak(controller->parentController());
|
||||
|
||||
const auto bar = box->verticalLayout()->add(
|
||||
object_ptr<Ui::Premium::TopBar>(
|
||||
box,
|
||||
|
@ -624,12 +630,44 @@ void CreateGiveawayBox(
|
|||
};
|
||||
}
|
||||
state->confirmButtonBusy = true;
|
||||
Payments::CheckoutProcess::Start(
|
||||
std::move(invoice),
|
||||
crl::guard(box, [=](auto) {
|
||||
const auto show = box->uiShow();
|
||||
const auto weak = Ui::MakeWeak(box.get());
|
||||
const auto done = [=](Payments::CheckoutResult result) {
|
||||
if (const auto strong = weak.data()) {
|
||||
state->confirmButtonBusy = false;
|
||||
box->window()->setFocus();
|
||||
}));
|
||||
strong->window()->setFocus();
|
||||
strong->closeBox();
|
||||
}
|
||||
if (result == Payments::CheckoutResult::Paid) {
|
||||
const auto filter = [=](const auto &...) {
|
||||
if (const auto window = weakWindow.get()) {
|
||||
window->showSection(Info::Boosts::Make(peer));
|
||||
}
|
||||
return false;
|
||||
};
|
||||
const auto title = isSpecific
|
||||
? tr::lng_giveaway_awarded_title
|
||||
: tr::lng_giveaway_created_title;
|
||||
const auto body = isSpecific
|
||||
? tr::lng_giveaway_awarded_body
|
||||
: tr::lng_giveaway_created_body;
|
||||
show->showToast({
|
||||
.text = Ui::Text::Bold(
|
||||
title(tr::now)).append('\n').append(
|
||||
body(
|
||||
tr::now,
|
||||
lt_link,
|
||||
Ui::Text::Link(
|
||||
tr::lng_giveaway_created_link(
|
||||
tr::now)),
|
||||
Ui::Text::WithEntities)),
|
||||
.duration = kDoneTooltipDuration,
|
||||
.adaptive = true,
|
||||
.filter = filter,
|
||||
});
|
||||
}
|
||||
};
|
||||
Payments::CheckoutProcess::Start(std::move(invoice), done);
|
||||
});
|
||||
box->addButton(std::move(button));
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 762a611f2009e623d6291ae5564bcd5fa4602e3d
|
||||
Subproject commit b8998700c4a34890cf20b7cad0a9225877101d69
|
Loading…
Add table
Reference in a new issue