mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Take premiumPossible in the accounts limit box correctly.
This commit is contained in:
parent
691a434ba9
commit
a34e6ca7db
2 changed files with 26 additions and 24 deletions
|
@ -1746,7 +1746,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_accounts_limit_title" = "Limit Reached";
|
||||
"lng_accounts_limit1#one" = "You have reached the limit of **{count}** connected accounts.";
|
||||
"lng_accounts_limit1#other" = "You have reached the limit of **{count}** connected accounts.";
|
||||
"lng_accounts_limit2" = "You can free one space by subscribing to **Telegram Premium** with on of these connected accounts:";
|
||||
"lng_accounts_limit2" = "You can free one space by subscribing to **Telegram Premium** with one of these connected accounts:";
|
||||
|
||||
"lng_group_about_header" = "You have created a group.";
|
||||
"lng_group_about_text" = "Groups can have:";
|
||||
|
|
|
@ -936,8 +936,20 @@ void AccountsLimitBox(
|
|||
const auto defaultLimit = Main::Domain::kMaxAccounts;
|
||||
const auto premiumLimit = Main::Domain::kPremiumMaxAccounts;
|
||||
|
||||
using Args = Ui::Premium::AccountsRowArgs;
|
||||
const auto accounts = session->domain().orderedAccounts();
|
||||
const auto premiumPossible = session->premiumPossible();
|
||||
auto promotePossible = ranges::views::all(
|
||||
accounts
|
||||
) | ranges::views::filter([&](not_null<Main::Account*> account) {
|
||||
return account->sessionExists()
|
||||
&& !account->session().premium()
|
||||
&& account->session().premiumPossible();
|
||||
}) | ranges::views::transform([&](not_null<Main::Account*> account) {
|
||||
const auto user = account->session().user();
|
||||
return Args::Entry{ user->name, PaintUserpicCallback(user, false) };
|
||||
}) | ranges::views::take(defaultLimit) | ranges::to_vector;
|
||||
|
||||
const auto premiumPossible = !promotePossible.empty();
|
||||
const auto current = int(accounts.size());
|
||||
|
||||
auto text = rpl::combine(
|
||||
|
@ -945,7 +957,7 @@ void AccountsLimitBox(
|
|||
lt_count,
|
||||
rpl::single<float64>(current),
|
||||
Ui::Text::RichLangValue),
|
||||
((current > premiumLimit)
|
||||
((!premiumPossible || current > premiumLimit)
|
||||
? rpl::single(TextWithEntities())
|
||||
: tr::lng_accounts_limit2(Ui::Text::RichLangValue))
|
||||
) | rpl::map([](TextWithEntities &&a, TextWithEntities &&b) {
|
||||
|
@ -970,9 +982,10 @@ void AccountsLimitBox(
|
|||
std::nullopt,
|
||||
&st::premiumIconAccounts);
|
||||
Settings::AddSkip(top, st::premiumLineTextSkip);
|
||||
Ui::Premium::AddLimitRow(top, 0, std::nullopt, defaultLimit);
|
||||
Settings::AddSkip(top, st::premiumInfographicPadding.bottom());
|
||||
|
||||
if (premiumPossible) {
|
||||
Ui::Premium::AddLimitRow(top, 0, std::nullopt, defaultLimit);
|
||||
Settings::AddSkip(top, st::premiumInfographicPadding.bottom());
|
||||
}
|
||||
box->setTitle(tr::lng_accounts_limit_title());
|
||||
|
||||
auto padding = st::boxPadding;
|
||||
|
@ -984,9 +997,7 @@ void AccountsLimitBox(
|
|||
st::aboutRevokePublicLabel),
|
||||
padding);
|
||||
|
||||
|
||||
if (current > premiumLimit) {
|
||||
// Probably an unreachable state.
|
||||
if (!premiumPossible || current > premiumLimit) {
|
||||
box->addButton(tr::lng_box_ok(), [=] {
|
||||
box->closeBox();
|
||||
});
|
||||
|
@ -1022,27 +1033,18 @@ void AccountsLimitBox(
|
|||
box->closeBox();
|
||||
});
|
||||
|
||||
using Args = Ui::Premium::AccountsRowArgs;
|
||||
|
||||
auto &&entries = ranges::views::all(
|
||||
accounts
|
||||
) | ranges::views::filter([&](not_null<Main::Account*> account) {
|
||||
return account->sessionExists() && !account->session().premium();
|
||||
}) | ranges::views::transform([&](not_null<Main::Account*> account) {
|
||||
const auto user = account->session().user();
|
||||
return Args::Entry{ user->name, PaintUserpicCallback(user, false) };
|
||||
}) | ranges::views::take(defaultLimit);
|
||||
|
||||
auto args = Args{
|
||||
.group = group,
|
||||
.st = st::premiumAccountsCheckbox,
|
||||
.stName = st::shareBoxListItem.nameStyle,
|
||||
.stNameFg = st::shareBoxListItem.nameFg,
|
||||
.entries = std::move(entries) | ranges::to_vector,
|
||||
.entries = std::move(promotePossible),
|
||||
};
|
||||
box->addSkip(st::premiumAccountsPadding.top());
|
||||
Ui::Premium::AddAccountsRow(box->verticalLayout(), std::move(args));
|
||||
box->addSkip(st::premiumAccountsPadding.bottom());
|
||||
if (!args.entries.empty()) {
|
||||
box->addSkip(st::premiumAccountsPadding.top());
|
||||
Ui::Premium::AddAccountsRow(box->verticalLayout(), std::move(args));
|
||||
box->addSkip(st::premiumAccountsPadding.bottom());
|
||||
}
|
||||
}
|
||||
|
||||
QString LimitsPremiumRef(const QString &addition) {
|
||||
|
|
Loading…
Add table
Reference in a new issue