app

Local-first trade for farms and co-ops
git clone https://radroots.dev/git/app.git
Log | Files | Refs | README | LICENSE

commit ba78de8f8b842ecfe6df5862da030fa9f483cf2a
parent 33f907deed5a0cac99a6b4b124569bd6d7cec155
Author: triesap <tyson@radroots.org>
Date:   Sun,  7 Jun 2026 13:52:51 -0700

fix: reset account route on surface selection

Diffstat:
Mcrates/state/src/lib.rs | 64+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 59 insertions(+), 5 deletions(-)

diff --git a/crates/state/src/lib.rs b/crates/state/src/lib.rs @@ -718,16 +718,12 @@ impl AppShellProjection { } fn select_active_surface(&mut self, active_surface: ActiveSurface) { - if self.active_surface == active_surface { - return; - } - self.active_surface = active_surface; match active_surface { ActiveSurface::Personal => { if matches!( self.selected_section, - ShellSection::Account | ShellSection::Farmer(_) + ShellSection::Home | ShellSection::Account | ShellSection::Farmer(_) ) { self.selected_section = ShellSection::default_for_surface(active_surface); } @@ -3940,6 +3936,64 @@ mod tests { } #[test] + fn select_active_surface_moves_account_route_to_personal_default() { + let repository = InMemoryAppStateRepository::new(AppShellProjection::new( + ActiveSurface::Personal, + ShellSection::Account, + )); + let mut store = AppStateStore::load(repository).expect("in-memory repository should load"); + assert_eq!( + store.apply(AppStateCommand::replace_identity_projection( + ready_identity(ActiveSurface::Personal,) + )), + Ok(true) + ); + + let changed = store.apply(AppStateCommand::select_active_surface( + ActiveSurface::Personal, + )); + + assert_eq!(changed, Ok(true)); + assert_eq!( + store.projection().shell.active_surface, + ActiveSurface::Personal + ); + assert_eq!( + store.projection().shell.selected_section, + ShellSection::Personal(PersonalSection::Browse) + ); + } + + #[test] + fn select_active_surface_moves_account_route_to_farmer_default() { + let repository = InMemoryAppStateRepository::new(AppShellProjection::new( + ActiveSurface::Farmer, + ShellSection::Account, + )); + let mut store = AppStateStore::load(repository).expect("in-memory repository should load"); + assert_eq!( + store.apply(AppStateCommand::replace_identity_projection( + ready_identity(ActiveSurface::Farmer,) + )), + Ok(true) + ); + + let changed = store.apply(AppStateCommand::select_active_surface( + ActiveSurface::Farmer, + )); + + assert_eq!(changed, Ok(true)); + assert_eq!( + store.projection().shell.active_surface, + ActiveSurface::Farmer + ); + assert_eq!( + store.projection().shell.selected_section, + ShellSection::Farmer(FarmerSection::Today) + ); + } + + #[test] fn select_active_surface_preserves_settings_route() { let repository = InMemoryAppStateRepository::new(AppShellProjection::for_settings( ActiveSurface::Personal,