[Improvement] Increase account limit
This commit is contained in:
parent
f715709401
commit
20cfd8e301
8 changed files with 66 additions and 20 deletions
|
|
@ -142,6 +142,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",
|
||||
|
|
@ -200,5 +202,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": ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -913,6 +913,7 @@ void FileSizeLimitBox(
|
|||
});
|
||||
}
|
||||
|
||||
/*
|
||||
void AccountsLimitBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<Main::Session*> session) {
|
||||
|
|
@ -1037,7 +1038,7 @@ void AccountsLimitBox(
|
|||
box->addSkip(st::premiumAccountsPadding.bottom());
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
QString LimitsPremiumRef(const QString &addition) {
|
||||
return "double_limits__" + addition;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,8 +53,10 @@ void FileSizeLimitBox(
|
|||
not_null<Ui::GenericBox*> box,
|
||||
not_null<Main::Session*> session,
|
||||
uint64 fileSizeBytes);
|
||||
/*
|
||||
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"
|
||||
|
|
@ -1767,10 +1768,11 @@ void DoubledLimitsPreviewBox(
|
|||
: (QString::number(nextMax) + QChar('+'));
|
||||
entries.push_back(Ui::Premium::ListEntry{
|
||||
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,
|
||||
|
|
|
|||
|
|
@ -296,6 +296,7 @@ void Application::run() {
|
|||
_primaryWindow->showAccount(account);
|
||||
}, _primaryWindow->widget()->lifetime());
|
||||
|
||||
/*
|
||||
(
|
||||
_domain->activeValue(
|
||||
) | rpl::to_empty | rpl::filter([=] {
|
||||
|
|
@ -320,6 +321,7 @@ void Application::run() {
|
|||
}
|
||||
}
|
||||
}, _primaryWindow->widget()->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();
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/widgets/menu/menu_add_action_callback.h"
|
||||
#include "boxes/abstract_box.h"
|
||||
#include "boxes/sessions_box.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "window/themes/window_theme_editor_box.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "window/window_controller.h"
|
||||
|
|
@ -329,11 +330,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), [=] {
|
||||
Ui::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 "editor/photo_editor_layer_widget.h"
|
||||
#include "settings/settings_common.h"
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
|
|
@ -806,15 +807,22 @@ not_null<Ui::SlideWrap<Ui::SettingsButton>*> AccountsList::setupAdd() {
|
|||
const auto button = result->entity();
|
||||
|
||||
const auto add = [=](MTP::Environment environment) {
|
||||
Core::App().preventOrInvoke([=] {
|
||||
auto &domain = _controller->session().domain();
|
||||
if (domain.accounts().size() >= domain.maxAccounts()) {
|
||||
_controller->show(
|
||||
Box(AccountsLimitBox, &_controller->session()));
|
||||
} else {
|
||||
domain.addActivated(environment);
|
||||
}
|
||||
});
|
||||
const auto sure = [=] {
|
||||
Core::App().preventOrInvoke([=] {
|
||||
Core::App().domain().addActivated(environment);
|
||||
});
|
||||
};
|
||||
if (_outerIndex >= Main::Domain::kMaxAccountsWarn) {
|
||||
Ui::show(
|
||||
Ui::MakeConfirmBox({
|
||||
.text = ktr("ktg_too_many_accounts_warning"),
|
||||
.confirmed = sure,
|
||||
.confirmText = ktr("ktg_account_add_anyway"),
|
||||
}),
|
||||
Ui::LayerOption::KeepOther);
|
||||
} else {
|
||||
sure();
|
||||
}
|
||||
};
|
||||
|
||||
button->setAcceptBoth(true);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue