2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-30 22:16:14 +00:00

Show toast on forward attempt to premium required.

This commit is contained in:
John Preston
2024-01-17 15:05:44 +04:00
parent 7c468052e6
commit eda7118df9
12 changed files with 428 additions and 64 deletions

View File

@@ -1316,6 +1316,22 @@ void ShowPremiumPromoToast(
std::shared_ptr<ChatHelpers::Show> show,
TextWithEntities textWithLink,
const QString &ref) {
ShowPremiumPromoToast(show, [=](
not_null<Main::Session*> session,
ChatHelpers::WindowUsage usage) {
Expects(&show->session() == session);
return show->resolveWindow(usage);
}, std::move(textWithLink), ref);
}
void ShowPremiumPromoToast(
std::shared_ptr<Main::SessionShow> show,
Fn<Window::SessionController*(
not_null<Main::Session*>,
ChatHelpers::WindowUsage)> resolveWindow,
TextWithEntities textWithLink,
const QString &ref) {
using WeakToast = base::weak_ptr<Ui::Toast::Instance>;
const auto toast = std::make_shared<WeakToast>();
(*toast) = show->showToast({
@@ -1331,7 +1347,8 @@ void ShowPremiumPromoToast(
if (const auto strong = toast->get()) {
strong->hideAnimated();
(*toast) = nullptr;
if (const auto controller = show->resolveWindow(
if (const auto controller = resolveWindow(
&show->session(),
ChatHelpers::WindowUsage::PremiumPromo)) {
Settings::ShowPremium(controller, ref);
}