[Improvement] Increase account limit
This commit is contained in:
parent
ce69f0f9ae
commit
6abe6de21f
8 changed files with 62 additions and 25 deletions
|
|
@ -127,6 +127,8 @@
|
|||
"ktg_channel_status_not_in": "not subscribed",
|
||||
"ktg_group_status_owner": "is owner",
|
||||
"ktg_group_status_admin": "is admin",
|
||||
"ktg_too_many_accounts_warning": "Warning! Using too many accounts at the same time is not recommended due to higher memory comsumption and possible crashes because of it.\n\nYou sure you want to add a new account?",
|
||||
"ktg_account_add_anyway": "Add anyway",
|
||||
"ktg_forward_go_to_chat": "Go to chat",
|
||||
"ktg_settings_forward": "Forward",
|
||||
"ktg_settings_forward_retain_selection": "Retain selection after forward",
|
||||
|
|
@ -185,5 +187,13 @@
|
|||
"ktg_settings_view_profile_on_top_about": "This option also enables \"Add \"View Profile\"\" from TDesktop's experimental settings.",
|
||||
"ktg_settings_emoji_sidebar": "Enable emoji sidebar",
|
||||
"ktg_settings_emoji_sidebar_right_click": "Emoji sidebar on right click",
|
||||
"ktg_premium_double_limits_about_accounts": {
|
||||
"zero": "Connect {count} accounts with different mobile numbers in official apps",
|
||||
"one": "Connect {count} account with different mobile numbers in official apps",
|
||||
"two": "Connect {count} accounts with different mobile numbers in official apps",
|
||||
"few": "Connect {count} accounts with different mobile numbers in official apps",
|
||||
"many": "Connect {count} accounts with different mobile numbers in official apps",
|
||||
"other": "Connect {count} accounts with different mobile numbers in official apps"
|
||||
},
|
||||
"dummy_last_string": ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1054,6 +1054,7 @@ void FileSizeLimitBox(
|
|||
});
|
||||
}
|
||||
|
||||
/*
|
||||
void AccountsLimitBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<Main::Session*> session) {
|
||||
|
|
@ -1180,7 +1181,7 @@ void AccountsLimitBox(
|
|||
box->addSkip(st::premiumAccountsPadding.bottom());
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
QString LimitsPremiumRef(const QString &addition) {
|
||||
return "double_limits__" + addition;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,8 +78,10 @@ void FileSizeLimitBox(
|
|||
not_null<Main::Session*> session,
|
||||
uint64 fileSizeBytes,
|
||||
const style::PremiumLimits *stOverride = nullptr);
|
||||
/*
|
||||
void AccountsLimitBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<Main::Session*> session);
|
||||
*/
|
||||
|
||||
[[nodiscard]] QString LimitsPremiumRef(const QString &addition);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#include "boxes/premium_preview_box.h"
|
||||
|
||||
#include "kotato/kotato_lang.h"
|
||||
#include "chat_helpers/stickers_lottie.h"
|
||||
#include "chat_helpers/stickers_emoji_pack.h"
|
||||
#include "data/data_file_origin.h"
|
||||
|
|
@ -1437,10 +1438,11 @@ void DoubledLimitsPreviewBox(
|
|||
: (QString::number(nextMax) + QChar('+'));
|
||||
entries.push_back({
|
||||
tr::lng_premium_double_limits_subtitle_accounts(),
|
||||
tr::lng_premium_double_limits_about_accounts(
|
||||
lt_count,
|
||||
rpl::single(float64(Main::Domain::kPremiumMaxAccounts)),
|
||||
Ui::Text::RichLangValue),
|
||||
rpl::single(Ui::Text::RichLangValue(
|
||||
ktr("ktg_premium_double_limits_about_accounts",
|
||||
float64(Main::Domain::kPremiumMaxAccounts),
|
||||
{ "count", QString::number(Main::Domain::kPremiumMaxAccounts)})
|
||||
)),
|
||||
Main::Domain::kMaxAccounts,
|
||||
Main::Domain::kPremiumMaxAccounts,
|
||||
till,
|
||||
|
|
|
|||
|
|
@ -323,6 +323,7 @@ void Application::run() {
|
|||
showAccount(account);
|
||||
}, _lifetime);
|
||||
|
||||
/*
|
||||
(
|
||||
_domain->activeValue(
|
||||
) | rpl::to_empty | rpl::filter([=] {
|
||||
|
|
@ -347,6 +348,7 @@ void Application::run() {
|
|||
}
|
||||
}
|
||||
}, _lifetime);
|
||||
*/
|
||||
|
||||
QCoreApplication::instance()->installEventFilter(this);
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#pragma once
|
||||
|
||||
#include "base/timer.h"
|
||||
#include "base/build_config.h"
|
||||
|
||||
namespace Storage {
|
||||
class Domain;
|
||||
|
|
@ -30,8 +31,13 @@ public:
|
|||
std::unique_ptr<Account> account;
|
||||
};
|
||||
|
||||
static constexpr auto kMaxAccounts = 3;
|
||||
static constexpr auto kMaxAccountsWarn = 3;
|
||||
static constexpr auto kPremiumMaxAccounts = 6;
|
||||
#ifdef ARCH_CPU_64_BITS
|
||||
static constexpr auto kMaxAccounts = 100;
|
||||
#else
|
||||
static constexpr auto kMaxAccounts = 10;
|
||||
#endif
|
||||
|
||||
explicit Domain(const QString &dataName);
|
||||
~Domain();
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "settings/settings_main.h"
|
||||
#include "settings/settings_notifications.h"
|
||||
#include "settings/settings_privacy_security.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "ui/widgets/menu/menu_add_action_callback.h"
|
||||
#include "window/themes/window_theme_editor_box.h"
|
||||
#include "window/window_controller.h"
|
||||
|
|
@ -60,11 +61,25 @@ void FillMenu(
|
|||
[=] { api->cloudPassword().clearUnconfirmedPassword(); },
|
||||
&st::menuIconCancel);
|
||||
} else {
|
||||
const auto &list = Core::App().domain().accounts();
|
||||
if (list.size() < Core::App().domain().maxAccounts()) {
|
||||
addAction(tr::lng_menu_add_account(tr::now), [=] {
|
||||
Core::App().domain().addActivated(MTP::Environment{});
|
||||
}, &st::menuIconAddAccount);
|
||||
if (type != Kotato::Id()) {
|
||||
const auto &list = Core::App().domain().accounts();
|
||||
if (list.size() < ::Main::Domain::kMaxAccountsWarn) {
|
||||
addAction(tr::lng_menu_add_account(tr::now), [=] {
|
||||
Core::App().domain().addActivated(MTP::Environment{});
|
||||
}, &st::menuIconAddAccount);
|
||||
} else if (list.size() < ::Main::Domain::kMaxAccounts) {
|
||||
addAction(tr::lng_menu_add_account(tr::now), [=] {
|
||||
controller->show(
|
||||
Ui::MakeConfirmBox({
|
||||
.text = ktr("ktg_too_many_accounts_warning"),
|
||||
.confirmed = [=] {
|
||||
Core::App().domain().addActivated(MTP::Environment{});
|
||||
},
|
||||
.confirmText = ktr("ktg_account_add_anyway"),
|
||||
}),
|
||||
Ui::LayerOption::KeepOther);
|
||||
}, &st::menuIconAddAccount);
|
||||
}
|
||||
}
|
||||
const auto customSettingsFile = cWorkingDir() + "tdata/kotato-settings-custom.json";
|
||||
if (type != Kotato::Id() && !controller->session().supportMode()) {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#include "settings/settings_information.h"
|
||||
|
||||
#include "kotato/kotato_lang.h"
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
#include "ui/wrap/vertical_layout_reorder.h"
|
||||
#include "ui/wrap/padding_wrap.h"
|
||||
|
|
@ -789,23 +790,21 @@ not_null<Ui::SlideWrap<Ui::SettingsButton>*> AccountsList::setupAdd() {
|
|||
using Environment = MTP::Environment;
|
||||
const auto add = [=](Environment environment, bool newWindow = false) {
|
||||
auto &domain = _controller->session().domain();
|
||||
auto found = false;
|
||||
for (const auto &[index, account] : domain.accounts()) {
|
||||
const auto raw = account.get();
|
||||
if (!raw->sessionExists()
|
||||
&& raw->mtp().environment() == environment) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if (!found && domain.accounts().size() >= domain.maxAccounts()) {
|
||||
_controller->show(
|
||||
Box(AccountsLimitBox, &_controller->session()));
|
||||
} else if (newWindow) {
|
||||
domain.addActivated(environment, true);
|
||||
} else {
|
||||
const auto sure = [=] {
|
||||
_controller->window().preventOrInvoke([=] {
|
||||
_controller->session().domain().addActivated(environment);
|
||||
});
|
||||
};
|
||||
if (domain.accounts().size() >= Main::Domain::kMaxAccountsWarn) {
|
||||
_controller->show(
|
||||
Ui::MakeConfirmBox({
|
||||
.text = ktr("ktg_too_many_accounts_warning"),
|
||||
.confirmed = sure,
|
||||
.confirmText = ktr("ktg_account_add_anyway"),
|
||||
}),
|
||||
Ui::LayerOption::KeepOther);
|
||||
} else {
|
||||
sure();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue