mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-18 22:17:01 +00:00
Moved Settings::OrderedAccounts() to Main::Domain::orderedAccounts().
This commit is contained in:
parent
a1736de977
commit
287fae858e
@ -27,7 +27,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "data/data_session.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "settings/settings_common.h"
|
||||
#include "settings/settings_information.h" // Settings::OrderedAccounts().
|
||||
#include "settings/settings_premium.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "apiwrap.h"
|
||||
@ -893,7 +892,7 @@ void AccountsLimitBox(
|
||||
const auto defaultLimit = Main::Domain::kMaxAccounts;
|
||||
const auto premiumLimit = Main::Domain::kPremiumMaxAccounts;
|
||||
|
||||
const auto accounts = Settings::OrderedAccounts();
|
||||
const auto accounts = session->domain().orderedAccounts();
|
||||
const auto current = int(accounts.size());
|
||||
|
||||
auto text = tr::lng_accounts_limit1(
|
||||
|
@ -140,6 +140,27 @@ const std::vector<Domain::AccountWithIndex> &Domain::accounts() const {
|
||||
return _accounts;
|
||||
}
|
||||
|
||||
std::vector<not_null<Account*>> Domain::orderedAccounts() const {
|
||||
const auto order = Core::App().settings().accountsOrder();
|
||||
auto accounts = ranges::views::all(
|
||||
_accounts
|
||||
) | ranges::views::transform([](const Domain::AccountWithIndex &a) {
|
||||
return not_null{ a.account.get() };
|
||||
}) | ranges::to_vector;
|
||||
ranges::stable_sort(accounts, [&](
|
||||
not_null<Account*> a,
|
||||
not_null<Account*> b) {
|
||||
const auto aIt = a->sessionExists()
|
||||
? ranges::find(order, a->session().uniqueId())
|
||||
: end(order);
|
||||
const auto bIt = b->sessionExists()
|
||||
? ranges::find(order, b->session().uniqueId())
|
||||
: end(order);
|
||||
return aIt < bIt;
|
||||
});
|
||||
return accounts;
|
||||
}
|
||||
|
||||
rpl::producer<> Domain::accountsChanges() const {
|
||||
return _accountsChanges.events();
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ public:
|
||||
|
||||
[[nodiscard]] auto accounts() const
|
||||
-> const std::vector<AccountWithIndex> &;
|
||||
[[nodiscard]] std::vector<not_null<Account*>> orderedAccounts() const;
|
||||
[[nodiscard]] rpl::producer<Account*> activeValue() const;
|
||||
[[nodiscard]] rpl::producer<> accountsChanges() const;
|
||||
[[nodiscard]] Account *maybeLastOrSomeAuthedAccount();
|
||||
|
@ -749,7 +749,7 @@ void AccountsList::rebuild() {
|
||||
}
|
||||
}, inner->lifetime());
|
||||
|
||||
const auto list = OrderedAccounts();
|
||||
const auto list = _controller->session().domain().orderedAccounts();
|
||||
for (const auto &account : list) {
|
||||
auto i = _watched.find(account);
|
||||
Assert(i != _watched.end());
|
||||
@ -830,29 +830,6 @@ AccountsEvents SetupAccounts(
|
||||
};
|
||||
}
|
||||
|
||||
std::vector<not_null<Main::Account*>> OrderedAccounts() {
|
||||
using namespace Main;
|
||||
|
||||
const auto order = Core::App().settings().accountsOrder();
|
||||
auto accounts = ranges::views::all(
|
||||
Core::App().domain().accounts()
|
||||
) | ranges::views::transform([](const Domain::AccountWithIndex &a) {
|
||||
return not_null{ a.account.get() };
|
||||
}) | ranges::to_vector;
|
||||
ranges::stable_sort(accounts, [&](
|
||||
not_null<Account*> a,
|
||||
not_null<Account*> b) {
|
||||
const auto aIt = a->sessionExists()
|
||||
? ranges::find(order, a->session().uniqueId())
|
||||
: end(order);
|
||||
const auto bIt = b->sessionExists()
|
||||
? ranges::find(order, b->session().uniqueId())
|
||||
: end(order);
|
||||
return aIt < bIt;
|
||||
});
|
||||
return accounts;
|
||||
}
|
||||
|
||||
Dialogs::Ui::UnreadBadgeStyle BadgeStyle() {
|
||||
auto result = Dialogs::Ui::UnreadBadgeStyle();
|
||||
result.font = st::mainMenuBadgeFont;
|
||||
|
@ -39,7 +39,6 @@ AccountsEvents SetupAccounts(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
not_null<Window::SessionController*> controller);
|
||||
|
||||
[[nodiscard]] std::vector<not_null<::Main::Account*>> OrderedAccounts();
|
||||
[[nodiscard]] Dialogs::Ui::UnreadBadgeStyle BadgeStyle();
|
||||
|
||||
struct UnreadBadge {
|
||||
|
Loading…
Reference in New Issue
Block a user