diff --git a/src/actionbar.rs b/src/actionbar.rs index 128909b..7bbd0ea 100644 --- a/src/actionbar.rs +++ b/src/actionbar.rs @@ -40,7 +40,6 @@ fn open_thread( ) -> Option { { router.route_to(Route::thread(NoteId::new(selected_note.to_owned()))); - router.navigating = true; } let root_id = crate::note::root_note_id_from_selected_id(ndb, note_cache, txn, selected_note); diff --git a/src/app.rs b/src/app.rs index 9fe6a2e..0fcd34f 100644 --- a/src/app.rs +++ b/src/app.rs @@ -3,7 +3,7 @@ use crate::{ app_creation::setup_cc, app_style::user_requested_visuals_change, args::Args, - column::Columns, + column::{Column, Columns}, draft::Drafts, error::{Error, FilterError}, filter, @@ -14,6 +14,7 @@ use crate::{ nav, note::NoteRef, notecache::{CachedNote, NoteCache}, + route::Route, subscriptions::{SubKind, Subscriptions}, thread::Threads, timeline::{Timeline, TimelineKind, ViewFilter}, @@ -962,11 +963,18 @@ fn timelines_view(ui: &mut egui::Ui, sizes: Size, app: &mut Damus, columns: usiz let rect = ui.available_rect_before_wrap(); let side_panel = DesktopSidePanel::new(app).show(ui); - if side_panel.response.clicked() { - info!("clicked {:?}", side_panel.action); - } + let router = if let Some(router) = + app.columns.columns_mut().get_mut(0).map(|c: &mut Column| c.router_mut()) + { + router + } else { + // TODO(jb55): Maybe we should have an empty column route? + let columns = app.columns.columns_mut(); + columns.push(Column::new(vec![Route::accounts()])); + columns[0].router_mut() + }; - DesktopSidePanel::perform_action(app, side_panel.action); + DesktopSidePanel::perform_action(router, side_panel.action); // vertical sidebar line ui.painter().vline( diff --git a/src/route.rs b/src/route.rs index 259132c..6be6fc3 100644 --- a/src/route.rs +++ b/src/route.rs @@ -68,6 +68,7 @@ impl Router { } pub fn route_to(&mut self, route: R) { + self.navigating = true; self.routes.push(route); } diff --git a/src/ui/side_panel.rs b/src/ui/side_panel.rs index dc9de6b..bc2f811 100644 --- a/src/ui/side_panel.rs +++ b/src/ui/side_panel.rs @@ -1,6 +1,11 @@ use egui::{Button, Layout, SidePanel, Vec2, Widget}; -use crate::{ui::profile_preview_controller, Damus}; +use crate::{ + column::Column, + route::{Route, Router}, + ui::profile_preview_controller, + Damus, +}; use super::{ProfilePic, View}; @@ -80,10 +85,13 @@ impl<'a> DesktopSidePanel<'a> { } } - pub fn perform_action(app: &mut Damus, action: SidePanelAction) { + pub fn perform_action(router: &mut Router, action: SidePanelAction) { match action { SidePanelAction::Panel => {} // TODO - SidePanelAction::Account => app.show_account_switcher = !app.show_account_switcher, + SidePanelAction::Account => { + router.route_to(Route::accounts()); + //app.show_account_switcher = !app.show_account_switcher, + } SidePanelAction::Settings => {} // TODO SidePanelAction::Columns => (), // TODO } @@ -138,7 +146,10 @@ mod preview { impl DesktopSidePanelPreview { fn new() -> Self { - let app = test_data::test_app(); + let mut app = test_data::test_app(); + app.columns + .columns_mut() + .push(Column::new(vec![Route::accounts()])); DesktopSidePanelPreview { app } } } @@ -153,7 +164,11 @@ mod preview { strip.cell(|ui| { let mut panel = DesktopSidePanel::new(&mut self.app); let response = panel.show(ui); - DesktopSidePanel::perform_action(&mut self.app, response.action); + + DesktopSidePanel::perform_action( + self.app.columns.columns_mut()[0].router_mut(), + response.action, + ); }); });