From 80077905a64b2d804c20a49d190f742a244d7816 Mon Sep 17 00:00:00 2001 From: edouardparis Date: Wed, 14 Aug 2024 11:32:25 +0200 Subject: [PATCH] Revert ctx state for remote backend when user clicks on previous --- gui/src/installer/mod.rs | 4 ++++ gui/src/installer/step/backend.rs | 6 ++++++ gui/src/installer/step/mod.rs | 1 + 3 files changed, 11 insertions(+) diff --git a/gui/src/installer/mod.rs b/gui/src/installer/mod.rs index cd475f1f..8d4c8157 100644 --- a/gui/src/installer/mod.rs +++ b/gui/src/installer/mod.rs @@ -72,6 +72,10 @@ impl Installer { { self.current -= 1; } + + if let Some(step) = self.steps.get(self.current) { + step.revert(&mut self.context) + } } pub fn new( diff --git a/gui/src/installer/step/backend.rs b/gui/src/installer/step/backend.rs index 5b2ed387..64fcd91d 100644 --- a/gui/src/installer/step/backend.rs +++ b/gui/src/installer/step/backend.rs @@ -260,6 +260,12 @@ impl Step for ChooseBackend { true } + /// If user clicks on previous to get back to the select backend, we revert the applied remote + /// backend on the context. + fn revert(&self, ctx: &mut Context) { + ctx.remote_backend = None; + } + fn view<'a>( &'a self, _hws: &'a HardwareWallets, diff --git a/gui/src/installer/step/mod.rs b/gui/src/installer/step/mod.rs index 08ade031..b1b3fc95 100644 --- a/gui/src/installer/step/mod.rs +++ b/gui/src/installer/step/mod.rs @@ -50,6 +50,7 @@ pub trait Step { fn apply(&mut self, _ctx: &mut Context) -> bool { true } + fn revert(&self, _ctx: &mut Context) {} fn stop(&self) {} }