diff --git a/client/src/modes/general/navigation.rs b/client/src/modes/general/navigation.rs index a0a927e..28ae1da 100644 --- a/client/src/modes/general/navigation.rs +++ b/client/src/modes/general/navigation.rs @@ -93,7 +93,7 @@ pub fn move_up(app_state: &mut AppState, login_state: &mut LoginState, register_ register_state.set_current_field(last_field_index); } } else { - app_state.focused_button_index = app_state.general.selected_item.saturating_sub(1); + app_state.focused_button_index = app_state.focused_button_index.saturating_sub(1); } } else if app_state.ui.show_intro { app_state.ui.intro_state.previous_option(); @@ -121,7 +121,7 @@ pub fn next_option(app_state: &mut AppState) { // Remove option_count parameter } else { // Get option count from state instead of parameter let option_count = app_state.profile_tree.profiles.len(); - app_state.general.current_option = (app_state.general.current_option + 1) % option_count; + app_state.focused_button_index = (app_state.focused_button_index + 1) % option_count; } } @@ -130,10 +130,10 @@ pub fn previous_option(app_state: &mut AppState) { app_state.ui.intro_state.previous_option(); } else { let option_count = app_state.profile_tree.profiles.len(); - app_state.general.current_option = if app_state.general.current_option == 0 { + app_state.focused_button_index = if app_state.focused_button_index == 0 { option_count.saturating_sub(1) } else { - app_state.general.current_option - 1 + app_state.focused_button_index - 1 }; } } diff --git a/client/src/state/pages/admin.rs b/client/src/state/pages/admin.rs index dc9e6c0..1a12c1b 100644 --- a/client/src/state/pages/admin.rs +++ b/client/src/state/pages/admin.rs @@ -34,5 +34,32 @@ impl AdminState { self.list_state.select(new_selection); } } + + /// Selects the next profile in the list, wrapping around. + pub fn next(&mut self) { + if self.profiles.is_empty() { + self.list_state.select(None); + return; + } + let i = match self.list_state.selected() { + Some(i) => if i >= self.profiles.len() - 1 { 0 } else { i + 1 }, + None => 0, + }; + self.list_state.select(Some(i)); + } + + /// Selects the previous profile in the list, wrapping around. + pub fn previous(&mut self) { + if self.profiles.is_empty() { + self.list_state.select(None); + return; + } + let i = match self.list_state.selected() { + Some(i) => if i == 0 { self.profiles.len() - 1 } else { i - 1 }, + None => self.profiles.len() - 1, + }; + self.list_state.select(Some(i)); + } + }