Skip to content
Snippets Groups Projects
Commit d287f5b5 authored by Adrien Béraud's avatar Adrien Béraud Committed by Sébastien Blin
Browse files

manager: make getAllAccounts return accounts not in the order list


Change-Id: I6ad737887943bb49d61d38a38c0fb7534fb6c564
Reviewed-by: default avatarSebastien Blin <sebastien.blin@savoirfairelinux.com>
parent 9b3d4c45
No related branches found
No related tags found
No related merge requests found
......@@ -41,6 +41,7 @@
#include <memory>
#include <atomic>
#include <functional>
#include <algorithm>
namespace ring {
......@@ -765,18 +766,17 @@ class Manager {
*/
template <class T=Account>
std::vector<std::shared_ptr<T>> getAllAccounts() const {
auto account_order = loadAccountOrder();
const auto& account_order = loadAccountOrder();
const auto& all_accounts = accountFactory.getAllAccounts<T>();
std::vector<std::shared_ptr<T>> accountList;
// If no order has been set, load the default one ie according to the creation date.
if (account_order.empty()) {
for (const auto &account : accountFactory.getAllAccounts<T>())
accountList.emplace_back(account);
} else {
accountList.reserve(all_accounts.size());
for (const auto& id : account_order) {
if (auto acc = accountFactory.getAccount<T>(id))
accountList.push_back(acc);
}
for (const auto& account : all_accounts) {
if (std::find(accountList.begin(), accountList.end(), account) == accountList.end())
accountList.emplace_back(account);
}
return accountList;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment