2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Improved processing of premium accounts limits.

This commit is contained in:
23rd
2022-06-02 11:27:00 +03:00
parent 6c48abb562
commit 1d7e901b7a
5 changed files with 79 additions and 43 deletions

View File

@@ -467,11 +467,11 @@ void Domain::scheduleWriteAccounts() {
}
int Domain::maxAccounts() const {
const auto isAnyPreimium = ranges::any_of(accounts(), [](
const auto premiumCount = ranges::count_if(accounts(), [](
const Main::Domain::AccountWithIndex &d) {
return d.account->session().premium();
return d.account->sessionExists() && d.account->session().premium();
});
return isAnyPreimium ? kPremiumMaxAccounts : kMaxAccounts;
return std::min(int(premiumCount) + kMaxAccounts, kPremiumMaxAccounts);
}
rpl::producer<int> Domain::maxAccountsChanges() const {

View File

@@ -31,7 +31,7 @@ public:
};
static constexpr auto kMaxAccounts = 3;
static constexpr auto kPremiumMaxAccounts = 4;
static constexpr auto kPremiumMaxAccounts = 6;
explicit Domain(const QString &dataName);
~Domain();