From 73eb1d38e3612110ad467fd608863519838aa988 Mon Sep 17 00:00:00 2001 From: edouard Date: Fri, 16 Dec 2022 19:14:51 +0100 Subject: [PATCH] fix state: add new hws in list without dropping the old ones It should be a solution for #238 --- gui/src/app/state/recovery.rs | 7 ++++++- gui/src/app/state/spend/detail.rs | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/gui/src/app/state/recovery.rs b/gui/src/app/state/recovery.rs index be66c6fe..d7d02333 100644 --- a/gui/src/app/state/recovery.rs +++ b/gui/src/app/state/recovery.rs @@ -118,8 +118,13 @@ impl State for RecoveryPanel { } } }, + // We add the new hws without dropping the reference of the previous ones. Message::ConnectedHardwareWallets(hws) => { - self.hws = hws; + for h in hws { + if !self.hws.iter().any(|hw| hw.fingerprint == h.fingerprint) { + self.hws.push(h); + } + } } Message::Psbt(res) => match res { Ok(psbt) => self.generated = Some(psbt), diff --git a/gui/src/app/state/spend/detail.rs b/gui/src/app/state/spend/detail.rs index fb578841..709a5a73 100644 --- a/gui/src/app/state/spend/detail.rs +++ b/gui/src/app/state/spend/detail.rs @@ -330,8 +330,13 @@ impl Action for SignAction { Ok(()) => self.updated = true, Err(e) => self.error = Some(e), }, + // We add the new hws without dropping the reference of the previous ones. Message::ConnectedHardwareWallets(hws) => { - self.hws = hws; + for h in hws { + if !self.hws.iter().any(|hw| hw.fingerprint == h.fingerprint) { + self.hws.push(h); + } + } } Message::View(view::Message::Reload) => { return self.load(daemon);