Replaced Session Controller with Navigation for resolving of giftcodes.

This commit is contained in:
23rd 2023-11-01 15:47:25 +03:00
parent 5966c74a27
commit 597195a2e2
2 changed files with 14 additions and 13 deletions

View File

@ -281,7 +281,7 @@ struct GiftCodeLink {
[[nodiscard]] object_ptr<Ui::RpWidget> MakePeerTableValue( [[nodiscard]] object_ptr<Ui::RpWidget> MakePeerTableValue(
not_null<QWidget*> parent, not_null<QWidget*> parent,
not_null<Window::SessionController*> controller, not_null<Window::SessionNavigation*> controller,
PeerId id) { PeerId id) {
auto result = object_ptr<Ui::AbstractButton>(parent); auto result = object_ptr<Ui::AbstractButton>(parent);
const auto raw = result.data(); const auto raw = result.data();
@ -309,7 +309,7 @@ struct GiftCodeLink {
label->setTextColorOverride(st::windowActiveTextFg->c); label->setTextColorOverride(st::windowActiveTextFg->c);
raw->setClickedCallback([=] { raw->setClickedCallback([=] {
controller->show(PrepareShortInfoBox(peer, controller)); controller->uiShow()->showBox(PrepareShortInfoBox(peer, controller));
}); });
return result; return result;
@ -350,7 +350,7 @@ not_null<Ui::FlatLabel*> AddTableRow(
void AddTableRow( void AddTableRow(
not_null<Ui::TableLayout*> table, not_null<Ui::TableLayout*> table,
rpl::producer<QString> label, rpl::producer<QString> label,
not_null<Window::SessionController*> controller, not_null<Window::SessionNavigation*> controller,
PeerId id) { PeerId id) {
if (!id) { if (!id) {
return; return;
@ -416,7 +416,7 @@ QString GiftDuration(int months) {
void GiftCodeBox( void GiftCodeBox(
not_null<Ui::GenericBox*> box, not_null<Ui::GenericBox*> box,
not_null<Window::SessionController*> controller, not_null<Window::SessionNavigation*> controller,
const QString &slug) { const QString &slug) {
struct State { struct State {
rpl::variable<Api::GiftCode> data; rpl::variable<Api::GiftCode> data;
@ -552,7 +552,7 @@ void GiftCodeBox(
st::giveawayGiftCodeFooterMargin); st::giveawayGiftCodeFooterMargin);
footer->setClickHandlerFilter([=](const auto &...) { footer->setClickHandlerFilter([=](const auto &...) {
const auto chosen = [=](not_null<Data::Thread*> thread) { const auto chosen = [=](not_null<Data::Thread*> thread) {
const auto content = controller->content(); const auto content = controller->parentController()->content();
return content->shareUrl( return content->shareUrl(
thread, thread,
MakeGiftCodeLink(&controller->session(), slug).link, MakeGiftCodeLink(&controller->session(), slug).link,
@ -608,13 +608,13 @@ void GiftCodeBox(
} }
void ResolveGiftCode( void ResolveGiftCode(
not_null<Window::SessionController*> controller, not_null<Window::SessionNavigation*> controller,
const QString &slug) { const QString &slug) {
const auto done = [=](Api::GiftCode code) { const auto done = [=](Api::GiftCode code) {
if (!code) { if (!code) {
controller->showToast(tr::lng_gift_link_expired(tr::now)); controller->showToast(tr::lng_gift_link_expired(tr::now));
} else { } else {
controller->show(Box(GiftCodeBox, controller, slug)); controller->uiShow()->showBox(Box(GiftCodeBox, controller, slug));
} }
}; };
controller->session().api().premium().checkGiftCode( controller->session().api().premium().checkGiftCode(
@ -624,7 +624,7 @@ void ResolveGiftCode(
void GiveawayInfoBox( void GiveawayInfoBox(
not_null<Ui::GenericBox*> box, not_null<Ui::GenericBox*> box,
not_null<Window::SessionController*> controller, not_null<Window::SessionNavigation*> controller,
Data::Giveaway giveaway, Data::Giveaway giveaway,
Api::GiveawayInfo info) { Api::GiveawayInfo info) {
using State = Api::GiveawayState; using State = Api::GiveawayState;
@ -784,7 +784,7 @@ void GiveawayInfoBox(
} }
void ResolveGiveawayInfo( void ResolveGiveawayInfo(
not_null<Window::SessionController*> controller, not_null<Window::SessionNavigation*> controller,
not_null<PeerData*> peer, not_null<PeerData*> peer,
MsgId messageId, MsgId messageId,
Data::Giveaway giveaway) { Data::Giveaway giveaway) {
@ -793,7 +793,7 @@ void ResolveGiveawayInfo(
controller->showToast( controller->showToast(
tr::lng_confirm_phone_link_invalid(tr::now)); tr::lng_confirm_phone_link_invalid(tr::now));
} else { } else {
controller->show( controller->uiShow()->showBox(
Box(GiveawayInfoBox, controller, giveaway, info)); Box(GiveawayInfoBox, controller, giveaway, info));
} }
}; };

View File

@ -25,6 +25,7 @@ class GenericBox;
namespace Window { namespace Window {
class SessionController; class SessionController;
class SessionNavigation;
} // namespace Window } // namespace Window
class GiftPremiumValidator final { class GiftPremiumValidator final {
@ -47,14 +48,14 @@ private:
void GiftCodeBox( void GiftCodeBox(
not_null<Ui::GenericBox*> box, not_null<Ui::GenericBox*> box,
not_null<Window::SessionController*> controller, not_null<Window::SessionNavigation*> controller,
const QString &slug); const QString &slug);
void ResolveGiftCode( void ResolveGiftCode(
not_null<Window::SessionController*> controller, not_null<Window::SessionNavigation*> controller,
const QString &slug); const QString &slug);
void ResolveGiveawayInfo( void ResolveGiveawayInfo(
not_null<Window::SessionController*> controller, not_null<Window::SessionNavigation*> controller,
not_null<PeerData*> peer, not_null<PeerData*> peer,
MsgId messageId, MsgId messageId,
Data::Giveaway giveaway); Data::Giveaway giveaway);