[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_channel_status_not_in": "not subscribed",
 | 
				
			||||||
	"ktg_group_status_owner": "is owner",
 | 
						"ktg_group_status_owner": "is owner",
 | 
				
			||||||
	"ktg_group_status_admin": "is admin",
 | 
						"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_forward_go_to_chat": "Go to chat",
 | 
				
			||||||
	"ktg_settings_forward": "Forward",
 | 
						"ktg_settings_forward": "Forward",
 | 
				
			||||||
	"ktg_settings_forward_retain_selection": "Retain selection after 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_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": "Enable emoji sidebar",
 | 
				
			||||||
	"ktg_settings_emoji_sidebar_right_click": "Emoji sidebar on right click",
 | 
						"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": ""
 | 
						"dummy_last_string": ""
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -913,6 +913,7 @@ void FileSizeLimitBox(
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
void AccountsLimitBox(
 | 
					void AccountsLimitBox(
 | 
				
			||||||
		not_null<Ui::GenericBox*> box,
 | 
							not_null<Ui::GenericBox*> box,
 | 
				
			||||||
		not_null<Main::Session*> session) {
 | 
							not_null<Main::Session*> session) {
 | 
				
			||||||
| 
						 | 
					@ -1037,7 +1038,7 @@ void AccountsLimitBox(
 | 
				
			||||||
		box->addSkip(st::premiumAccountsPadding.bottom());
 | 
							box->addSkip(st::premiumAccountsPadding.bottom());
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
QString LimitsPremiumRef(const QString &addition) {
 | 
					QString LimitsPremiumRef(const QString &addition) {
 | 
				
			||||||
	return "double_limits__" + addition;
 | 
						return "double_limits__" + addition;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -53,8 +53,10 @@ void FileSizeLimitBox(
 | 
				
			||||||
	not_null<Ui::GenericBox*> box,
 | 
						not_null<Ui::GenericBox*> box,
 | 
				
			||||||
	not_null<Main::Session*> session,
 | 
						not_null<Main::Session*> session,
 | 
				
			||||||
	uint64 fileSizeBytes);
 | 
						uint64 fileSizeBytes);
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
void AccountsLimitBox(
 | 
					void AccountsLimitBox(
 | 
				
			||||||
	not_null<Ui::GenericBox*> box,
 | 
						not_null<Ui::GenericBox*> box,
 | 
				
			||||||
	not_null<Main::Session*> session);
 | 
						not_null<Main::Session*> session);
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[[nodiscard]] QString LimitsPremiumRef(const QString &addition);
 | 
					[[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 "boxes/premium_preview_box.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "kotato/kotato_lang.h"
 | 
				
			||||||
#include "chat_helpers/stickers_lottie.h"
 | 
					#include "chat_helpers/stickers_lottie.h"
 | 
				
			||||||
#include "chat_helpers/stickers_emoji_pack.h"
 | 
					#include "chat_helpers/stickers_emoji_pack.h"
 | 
				
			||||||
#include "data/data_file_origin.h"
 | 
					#include "data/data_file_origin.h"
 | 
				
			||||||
| 
						 | 
					@ -1767,10 +1768,11 @@ void DoubledLimitsPreviewBox(
 | 
				
			||||||
		: (QString::number(nextMax) + QChar('+'));
 | 
							: (QString::number(nextMax) + QChar('+'));
 | 
				
			||||||
	entries.push_back(Ui::Premium::ListEntry{
 | 
						entries.push_back(Ui::Premium::ListEntry{
 | 
				
			||||||
		tr::lng_premium_double_limits_subtitle_accounts(),
 | 
							tr::lng_premium_double_limits_subtitle_accounts(),
 | 
				
			||||||
		tr::lng_premium_double_limits_about_accounts(
 | 
							rpl::single(Ui::Text::RichLangValue(
 | 
				
			||||||
			lt_count,
 | 
								ktr("ktg_premium_double_limits_about_accounts",
 | 
				
			||||||
			rpl::single(float64(Main::Domain::kPremiumMaxAccounts)),
 | 
									float64(Main::Domain::kPremiumMaxAccounts),
 | 
				
			||||||
			Ui::Text::RichLangValue),
 | 
									{ "count", QString::number(Main::Domain::kPremiumMaxAccounts)})
 | 
				
			||||||
 | 
							)),
 | 
				
			||||||
		Main::Domain::kMaxAccounts,
 | 
							Main::Domain::kMaxAccounts,
 | 
				
			||||||
		Main::Domain::kPremiumMaxAccounts,
 | 
							Main::Domain::kPremiumMaxAccounts,
 | 
				
			||||||
		till,
 | 
							till,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -296,6 +296,7 @@ void Application::run() {
 | 
				
			||||||
		_primaryWindow->showAccount(account);
 | 
							_primaryWindow->showAccount(account);
 | 
				
			||||||
	}, _primaryWindow->widget()->lifetime());
 | 
						}, _primaryWindow->widget()->lifetime());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/*
 | 
				
			||||||
	(
 | 
						(
 | 
				
			||||||
		_domain->activeValue(
 | 
							_domain->activeValue(
 | 
				
			||||||
		) | rpl::to_empty | rpl::filter([=] {
 | 
							) | rpl::to_empty | rpl::filter([=] {
 | 
				
			||||||
| 
						 | 
					@ -320,6 +321,7 @@ void Application::run() {
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}, _primaryWindow->widget()->lifetime());
 | 
						}, _primaryWindow->widget()->lifetime());
 | 
				
			||||||
 | 
						*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QCoreApplication::instance()->installEventFilter(this);
 | 
						QCoreApplication::instance()->installEventFilter(this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 | 
				
			||||||
#pragma once
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "base/timer.h"
 | 
					#include "base/timer.h"
 | 
				
			||||||
 | 
					#include "base/build_config.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Storage {
 | 
					namespace Storage {
 | 
				
			||||||
class Domain;
 | 
					class Domain;
 | 
				
			||||||
| 
						 | 
					@ -30,8 +31,13 @@ public:
 | 
				
			||||||
		std::unique_ptr<Account> account;
 | 
							std::unique_ptr<Account> account;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	static constexpr auto kMaxAccounts = 3;
 | 
						static constexpr auto kMaxAccountsWarn = 3;
 | 
				
			||||||
	static constexpr auto kPremiumMaxAccounts = 6;
 | 
						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);
 | 
						explicit Domain(const QString &dataName);
 | 
				
			||||||
	~Domain();
 | 
						~Domain();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -31,6 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 | 
				
			||||||
#include "ui/widgets/menu/menu_add_action_callback.h"
 | 
					#include "ui/widgets/menu/menu_add_action_callback.h"
 | 
				
			||||||
#include "boxes/abstract_box.h"
 | 
					#include "boxes/abstract_box.h"
 | 
				
			||||||
#include "boxes/sessions_box.h"
 | 
					#include "boxes/sessions_box.h"
 | 
				
			||||||
 | 
					#include "ui/boxes/confirm_box.h"
 | 
				
			||||||
#include "window/themes/window_theme_editor_box.h"
 | 
					#include "window/themes/window_theme_editor_box.h"
 | 
				
			||||||
#include "window/window_session_controller.h"
 | 
					#include "window/window_session_controller.h"
 | 
				
			||||||
#include "window/window_controller.h"
 | 
					#include "window/window_controller.h"
 | 
				
			||||||
| 
						 | 
					@ -329,11 +330,25 @@ void FillMenu(
 | 
				
			||||||
			[=] { api->cloudPassword().clearUnconfirmedPassword(); },
 | 
								[=] { api->cloudPassword().clearUnconfirmedPassword(); },
 | 
				
			||||||
			&st::menuIconCancel);
 | 
								&st::menuIconCancel);
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		const auto &list = Core::App().domain().accounts();
 | 
							if (type != Kotato::Id()) {
 | 
				
			||||||
		if (list.size() < Core::App().domain().maxAccounts()) {
 | 
								const auto &list = Core::App().domain().accounts();
 | 
				
			||||||
			addAction(tr::lng_menu_add_account(tr::now), [=] {
 | 
								if (list.size() < ::Main::Domain::kMaxAccountsWarn) {
 | 
				
			||||||
				Core::App().domain().addActivated(MTP::Environment{});
 | 
									addAction(tr::lng_menu_add_account(tr::now), [=] {
 | 
				
			||||||
			}, &st::menuIconAddAccount);
 | 
										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";
 | 
							const auto customSettingsFile = cWorkingDir() + "tdata/kotato-settings-custom.json";
 | 
				
			||||||
		if (type != Kotato::Id() && !controller->session().supportMode()) {
 | 
							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 "settings/settings_information.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "kotato/kotato_lang.h"
 | 
				
			||||||
#include "editor/photo_editor_layer_widget.h"
 | 
					#include "editor/photo_editor_layer_widget.h"
 | 
				
			||||||
#include "settings/settings_common.h"
 | 
					#include "settings/settings_common.h"
 | 
				
			||||||
#include "ui/wrap/vertical_layout.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 button = result->entity();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const auto add = [=](MTP::Environment environment) {
 | 
						const auto add = [=](MTP::Environment environment) {
 | 
				
			||||||
		Core::App().preventOrInvoke([=] {
 | 
							const auto sure = [=] {
 | 
				
			||||||
			auto &domain = _controller->session().domain();
 | 
								Core::App().preventOrInvoke([=] {
 | 
				
			||||||
			if (domain.accounts().size() >= domain.maxAccounts()) {
 | 
									Core::App().domain().addActivated(environment);
 | 
				
			||||||
				_controller->show(
 | 
								});
 | 
				
			||||||
					Box(AccountsLimitBox, &_controller->session()));
 | 
							};
 | 
				
			||||||
			} else {
 | 
							if (_outerIndex >= Main::Domain::kMaxAccountsWarn) {
 | 
				
			||||||
				domain.addActivated(environment);
 | 
								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);
 | 
						button->setAcceptBoth(true);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue