mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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_limit_title" = "Limit Reached";
|
||||||
"lng_accounts_limit1#one" = "You have reached the limit of **{count}** connected accounts.";
|
"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_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_header" = "You have created a group.";
|
||||||
"lng_group_about_text" = "Groups can have:";
|
"lng_group_about_text" = "Groups can have:";
|
||||||
|
|
|
@ -936,8 +936,20 @@ void AccountsLimitBox(
|
||||||
const auto defaultLimit = Main::Domain::kMaxAccounts;
|
const auto defaultLimit = Main::Domain::kMaxAccounts;
|
||||||
const auto premiumLimit = Main::Domain::kPremiumMaxAccounts;
|
const auto premiumLimit = Main::Domain::kPremiumMaxAccounts;
|
||||||
|
|
||||||
|
using Args = Ui::Premium::AccountsRowArgs;
|
||||||
const auto accounts = session->domain().orderedAccounts();
|
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());
|
const auto current = int(accounts.size());
|
||||||
|
|
||||||
auto text = rpl::combine(
|
auto text = rpl::combine(
|
||||||
|
@ -945,7 +957,7 @@ void AccountsLimitBox(
|
||||||
lt_count,
|
lt_count,
|
||||||
rpl::single<float64>(current),
|
rpl::single<float64>(current),
|
||||||
Ui::Text::RichLangValue),
|
Ui::Text::RichLangValue),
|
||||||
((current > premiumLimit)
|
((!premiumPossible || current > premiumLimit)
|
||||||
? rpl::single(TextWithEntities())
|
? rpl::single(TextWithEntities())
|
||||||
: tr::lng_accounts_limit2(Ui::Text::RichLangValue))
|
: tr::lng_accounts_limit2(Ui::Text::RichLangValue))
|
||||||
) | rpl::map([](TextWithEntities &&a, TextWithEntities &&b) {
|
) | rpl::map([](TextWithEntities &&a, TextWithEntities &&b) {
|
||||||
|
@ -970,9 +982,10 @@ void AccountsLimitBox(
|
||||||
std::nullopt,
|
std::nullopt,
|
||||||
&st::premiumIconAccounts);
|
&st::premiumIconAccounts);
|
||||||
Settings::AddSkip(top, st::premiumLineTextSkip);
|
Settings::AddSkip(top, st::premiumLineTextSkip);
|
||||||
Ui::Premium::AddLimitRow(top, 0, std::nullopt, defaultLimit);
|
if (premiumPossible) {
|
||||||
Settings::AddSkip(top, st::premiumInfographicPadding.bottom());
|
Ui::Premium::AddLimitRow(top, 0, std::nullopt, defaultLimit);
|
||||||
|
Settings::AddSkip(top, st::premiumInfographicPadding.bottom());
|
||||||
|
}
|
||||||
box->setTitle(tr::lng_accounts_limit_title());
|
box->setTitle(tr::lng_accounts_limit_title());
|
||||||
|
|
||||||
auto padding = st::boxPadding;
|
auto padding = st::boxPadding;
|
||||||
|
@ -984,9 +997,7 @@ void AccountsLimitBox(
|
||||||
st::aboutRevokePublicLabel),
|
st::aboutRevokePublicLabel),
|
||||||
padding);
|
padding);
|
||||||
|
|
||||||
|
if (!premiumPossible || current > premiumLimit) {
|
||||||
if (current > premiumLimit) {
|
|
||||||
// Probably an unreachable state.
|
|
||||||
box->addButton(tr::lng_box_ok(), [=] {
|
box->addButton(tr::lng_box_ok(), [=] {
|
||||||
box->closeBox();
|
box->closeBox();
|
||||||
});
|
});
|
||||||
|
@ -1022,27 +1033,18 @@ void AccountsLimitBox(
|
||||||
box->closeBox();
|
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{
|
auto args = Args{
|
||||||
.group = group,
|
.group = group,
|
||||||
.st = st::premiumAccountsCheckbox,
|
.st = st::premiumAccountsCheckbox,
|
||||||
.stName = st::shareBoxListItem.nameStyle,
|
.stName = st::shareBoxListItem.nameStyle,
|
||||||
.stNameFg = st::shareBoxListItem.nameFg,
|
.stNameFg = st::shareBoxListItem.nameFg,
|
||||||
.entries = std::move(entries) | ranges::to_vector,
|
.entries = std::move(promotePossible),
|
||||||
};
|
};
|
||||||
box->addSkip(st::premiumAccountsPadding.top());
|
if (!args.entries.empty()) {
|
||||||
Ui::Premium::AddAccountsRow(box->verticalLayout(), std::move(args));
|
box->addSkip(st::premiumAccountsPadding.top());
|
||||||
box->addSkip(st::premiumAccountsPadding.bottom());
|
Ui::Premium::AddAccountsRow(box->verticalLayout(), std::move(args));
|
||||||
|
box->addSkip(st::premiumAccountsPadding.bottom());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString LimitsPremiumRef(const QString &addition) {
|
QString LimitsPremiumRef(const QString &addition) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue