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 @@ ...@@ -41,6 +41,7 @@
#include <memory> #include <memory>
#include <atomic> #include <atomic>
#include <functional> #include <functional>
#include <algorithm>
namespace ring { namespace ring {
...@@ -765,18 +766,17 @@ class Manager { ...@@ -765,18 +766,17 @@ class Manager {
*/ */
template <class T=Account> template <class T=Account>
std::vector<std::shared_ptr<T>> getAllAccounts() const { 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; std::vector<std::shared_ptr<T>> accountList;
accountList.reserve(all_accounts.size());
// 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 {
for (const auto& id : account_order) { for (const auto& id : account_order) {
if (auto acc = accountFactory.getAccount<T>(id)) if (auto acc = accountFactory.getAccount<T>(id))
accountList.push_back(acc); 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; return accountList;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment