mirror of
https://github.com/aljazceru/notedeck.git
synced 2025-12-18 00:54:21 +01:00
Merge remote-tracking branch 'github/jb55-deck-733-profile-sidebar-action-should-route-in-the-active-column'
This commit is contained in:
@@ -699,7 +699,7 @@ fn chrome_handle_app_action(
|
||||
);
|
||||
|
||||
if let Some(action) = m_action {
|
||||
let col = cols.column_mut(0);
|
||||
let col = cols.selected_mut();
|
||||
|
||||
action.process(&mut col.router, &mut col.sheet_router);
|
||||
}
|
||||
@@ -723,7 +723,7 @@ fn columns_route_to_profile(
|
||||
.active_columns_mut(ctx.i18n, ctx.accounts)
|
||||
.unwrap();
|
||||
|
||||
let router = cols.get_first_router();
|
||||
let router = cols.get_selected_router();
|
||||
if router.routes().iter().any(|r| {
|
||||
matches!(
|
||||
r,
|
||||
@@ -754,7 +754,7 @@ fn columns_route_to_profile(
|
||||
);
|
||||
|
||||
if let Some(action) = m_action {
|
||||
let col = cols.column_mut(0);
|
||||
let col = cols.selected_mut();
|
||||
|
||||
action.process(&mut col.router, &mut col.sheet_router);
|
||||
}
|
||||
|
||||
@@ -78,9 +78,7 @@ fn handle_key_events(input: &egui::InputState, columns: &mut Columns) {
|
||||
columns.select_left();
|
||||
}
|
||||
egui::Key::BrowserBack | egui::Key::Escape => {
|
||||
if let Some(column) = columns.selected_mut() {
|
||||
column.router_mut().go_back();
|
||||
}
|
||||
columns.get_selected_router().go_back();
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
@@ -156,11 +156,9 @@ impl Columns {
|
||||
|
||||
// Get the first router in the columns if there are columns present.
|
||||
// Otherwise, create a new column picker and return the router
|
||||
pub fn get_first_router(&mut self) -> &mut Router<Route> {
|
||||
if self.columns.is_empty() {
|
||||
self.new_column_picker();
|
||||
}
|
||||
self.columns[0].router_mut()
|
||||
pub fn get_selected_router(&mut self) -> &mut Router<Route> {
|
||||
self.ensure_column();
|
||||
self.selected_mut().router_mut()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@@ -181,19 +179,25 @@ impl Columns {
|
||||
Some(&self.columns[self.selected as usize])
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn selected_mut(&mut self) -> Option<&mut Column> {
|
||||
// TODO(jb55): switch to non-empty container for columns?
|
||||
fn ensure_column(&mut self) {
|
||||
if self.columns.is_empty() {
|
||||
return None;
|
||||
self.new_column_picker();
|
||||
}
|
||||
Some(&mut self.columns[self.selected as usize])
|
||||
}
|
||||
|
||||
/// Get the selected column. If you're looking to route something
|
||||
/// and you're not sure which one to choose, use this one
|
||||
#[inline]
|
||||
pub fn selected_mut(&mut self) -> &mut Column {
|
||||
self.ensure_column();
|
||||
assert!(self.selected < self.columns.len() as i32);
|
||||
&mut self.columns[self.selected as usize]
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn column_mut(&mut self, ind: usize) -> &mut Column {
|
||||
if self.columns.is_empty() {
|
||||
self.new_column_picker();
|
||||
}
|
||||
self.ensure_column();
|
||||
&mut self.columns[ind]
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ impl DecksCache {
|
||||
accounts: ¬edeck::Accounts,
|
||||
) -> Option<&mut Column> {
|
||||
self.active_columns_mut(i18n, accounts)
|
||||
.and_then(|ad| ad.selected_mut())
|
||||
.map(|ad| ad.selected_mut())
|
||||
}
|
||||
|
||||
pub fn selected_column(&self, accounts: ¬edeck::Accounts) -> Option<&Column> {
|
||||
|
||||
@@ -771,7 +771,7 @@ fn render_nav_body(
|
||||
|
||||
new_deck_state.clear();
|
||||
get_active_columns_mut(ctx.i18n, ctx.accounts, &mut app.decks_cache)
|
||||
.get_first_router()
|
||||
.get_selected_router()
|
||||
.go_back();
|
||||
}
|
||||
resp
|
||||
@@ -802,7 +802,7 @@ fn render_nav_body(
|
||||
}
|
||||
}
|
||||
get_active_columns_mut(ctx.i18n, ctx.accounts, &mut app.decks_cache)
|
||||
.get_first_router()
|
||||
.get_selected_router()
|
||||
.go_back();
|
||||
}
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ impl<'a> DesktopSidePanel<'a> {
|
||||
action: SidePanelAction,
|
||||
i18n: &mut Localization,
|
||||
) -> Option<SwitchingAction> {
|
||||
let router = get_active_columns_mut(i18n, accounts, decks_cache).get_first_router();
|
||||
let router = get_active_columns_mut(i18n, accounts, decks_cache).get_selected_router();
|
||||
let mut switching_response = None;
|
||||
match action {
|
||||
/*
|
||||
@@ -280,7 +280,7 @@ impl<'a> DesktopSidePanel<'a> {
|
||||
{
|
||||
edit_deck
|
||||
.columns_mut()
|
||||
.get_first_router()
|
||||
.get_selected_router()
|
||||
.route_to(Route::EditDeck(index));
|
||||
} else {
|
||||
error!("Cannot push EditDeck route to index {}", index);
|
||||
|
||||
Reference in New Issue
Block a user