diff --git a/client/src/pages/login/logic.rs b/client/src/pages/login/logic.rs index e0035f1..436e41c 100644 --- a/client/src/pages/login/logic.rs +++ b/client/src/pages/login/logic.rs @@ -132,11 +132,12 @@ pub async fn back_to_main( /// Validates input, shows loading, and spawns the login task. pub fn initiate_login( - login_state: &LoginFormState, + login_state: &mut LoginFormState, app_state: &mut AppState, mut auth_client: AuthClient, sender: mpsc::Sender, ) -> String { + login_state.sync_from_editor(); let username = login_state.username().to_string(); let password = login_state.password().to_string(); diff --git a/client/src/pages/login/state.rs b/client/src/pages/login/state.rs index d7483c5..ab6cd07 100644 --- a/client/src/pages/login/state.rs +++ b/client/src/pages/login/state.rs @@ -139,6 +139,13 @@ impl fmt::Debug for LoginFormState { } impl LoginFormState { + /// Sync the editor's data provider back into our state + pub fn sync_from_editor(&mut self) { + // FormEditor holds the authoritative data + let dp = self.editor.data_provider(); + self.state = dp.clone(); // LoginState implements Clone + } + /// Create a new LoginFormState with default LoginState and FormEditor pub fn new() -> Self { let state = LoginState::default(); diff --git a/client/src/pages/register/logic.rs b/client/src/pages/register/logic.rs index a62f4d7..ee7663e 100644 --- a/client/src/pages/register/logic.rs +++ b/client/src/pages/register/logic.rs @@ -62,11 +62,12 @@ pub async fn back_to_login( /// Validates input, shows loading, and spawns the registration task. pub fn initiate_registration( - register_state: &RegisterFormState, + register_state: &mut RegisterFormState, app_state: &mut AppState, mut auth_client: AuthClient, sender: mpsc::Sender, ) -> String { + register_state.sync_from_editor(); let username = register_state.username().to_string(); let email = register_state.email().to_string(); let password = register_state.password().to_string(); diff --git a/client/src/pages/register/state.rs b/client/src/pages/register/state.rs index 39bb393..faa41bf 100644 --- a/client/src/pages/register/state.rs +++ b/client/src/pages/register/state.rs @@ -206,6 +206,13 @@ impl fmt::Debug for RegisterFormState { } impl RegisterFormState { + /// Sync the editor's data provider back into our state + pub fn sync_from_editor(&mut self) { + // The FormEditor holds the authoritative data + let dp = self.editor.data_provider(); + self.state = dp.clone(); // because RegisterState: Clone + } + pub fn new() -> Self { let state = RegisterState::default(); let editor = FormEditor::new(state.clone());