2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 22:46:10 +00:00

Moved Settings::OrderedAccounts() to Main::Domain::orderedAccounts().

This commit is contained in:
23rd
2022-06-02 13:47:57 +03:00
parent a1736de977
commit 287fae858e
5 changed files with 24 additions and 27 deletions

View File

@@ -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();
}