From 7dc619d8cdd104cc6f903ed3ad1bd7f42b557dcb Mon Sep 17 00:00:00 2001
From: Adrien Beraud <adrien.beraud@savoirfairelinux.com>
Date: Sat, 15 Jul 2017 09:35:31 -0400
Subject: [PATCH] ringaccount: update registeredName if not found on the
 nameserver

Change-Id: I76a079c2222fcfac8cc5458e2ad33370983df167
---
 src/ringdht/ringaccount.cpp | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/ringdht/ringaccount.cpp b/src/ringdht/ringaccount.cpp
index 840c77147b..68e282ae8d 100644
--- a/src/ringdht/ringaccount.cpp
+++ b/src/ringdht/ringaccount.cpp
@@ -2119,13 +2119,19 @@ RingAccount::doRegister_()
 #if HAVE_RINGNS
         // Look for registered name on the blockchain
         nameDir_.get().lookupAddress(ringAccountId_, [w](const std::string& result, const NameDirectory::Response& response) {
-            if (response == NameDirectory::Response::found)
-                if (auto this_ = w.lock()) {
+            if (auto this_ = w.lock()) {
+                if (response == NameDirectory::Response::found) {
                     if (this_->registeredName_ != result) {
                         this_->registeredName_ = result;
                         emitSignal<DRing::ConfigurationSignal::VolatileDetailsChanged>(this_->accountID_, this_->getVolatileAccountDetails());
                     }
+                } else if (response == NameDirectory::Response::notFound) {
+                    if (not this_->registeredName_.empty()) {
+                        this_->registeredName_.clear();
+                        emitSignal<DRing::ConfigurationSignal::VolatileDetailsChanged>(this_->accountID_, this_->getVolatileAccountDetails());
+                    }
                 }
+            }
         });
 #endif
 
-- 
GitLab