From bc5b68413096766906d20cc55ac856410cec9e4b Mon Sep 17 00:00:00 2001
From: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
Date: Wed, 25 Sep 2019 12:17:41 -0400
Subject: [PATCH] account: update info after migration

Change-Id: I11474b70cc7de1ea8b9ac5d38f22686cb1289b07
---
 src/newaccountmodel.cpp | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/newaccountmodel.cpp b/src/newaccountmodel.cpp
index ec53e1d3..f24c162d 100644
--- a/src/newaccountmodel.cpp
+++ b/src/newaccountmodel.cpp
@@ -536,9 +536,17 @@ void
 NewAccountModelPimpl::slotMigrationEnded(const std::string& accountId, bool ok)
 {
     if (ok) {
-        // Previous account was incorrect, force a full reload
-        removeFromAccounts(accountId);
-        addToAccounts(accountId);
+        auto it = accounts.find(accountId);
+        if (it == accounts.end()) {
+            addToAccounts(accountId);
+            return;
+        }
+        auto& accountInfo = it->second.first;
+        MapStringString details = ConfigurationManager::instance().getAccountDetails(accountId.c_str());
+        accountInfo.fromDetails(details);
+        MapStringString volatileDetails = ConfigurationManager::instance().getVolatileAccountDetails(accountId.c_str());
+        std::string daemonStatus = volatileDetails[DRing::Account::ConfProperties::Registration::STATUS].toStdString();
+        accountInfo.status = lrc::api::account::to_status(daemonStatus);
     }
     emit linked.migrationEnded(accountId, ok);
 }
-- 
GitLab