mirror of
https://github.com/aljazceru/notedeck.git
synced 2025-12-19 09:34:19 +01:00
nav: move process nav response to own method
Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
@@ -142,53 +142,62 @@ impl RenderNavResponse {
|
|||||||
ctx: &mut AppContext<'_>,
|
ctx: &mut AppContext<'_>,
|
||||||
ui: &mut egui::Ui,
|
ui: &mut egui::Ui,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let mut switching_occured: bool = false;
|
process_nav_resp(app, ctx, ui, self.response, self.column)
|
||||||
let col = self.column;
|
|
||||||
|
|
||||||
if let Some(action) = self.response.response.or(self.response.title_response) {
|
|
||||||
// start returning when we're finished posting
|
|
||||||
|
|
||||||
switching_occured = process_render_nav_action(app, ctx, ui, col, action);
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(action) = self.response.action {
|
|
||||||
match action {
|
|
||||||
NavAction::Returned => {
|
|
||||||
let r = app
|
|
||||||
.columns_mut(ctx.accounts)
|
|
||||||
.column_mut(col)
|
|
||||||
.router_mut()
|
|
||||||
.pop();
|
|
||||||
|
|
||||||
if let Some(Route::Timeline(kind)) = &r {
|
|
||||||
if let Err(err) = app.timeline_cache.pop(kind, ctx.ndb, ctx.pool) {
|
|
||||||
error!("popping timeline had an error: {err} for {:?}", kind);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
switching_occured = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
NavAction::Navigated => {
|
|
||||||
let cur_router = app.columns_mut(ctx.accounts).column_mut(col).router_mut();
|
|
||||||
cur_router.navigating = false;
|
|
||||||
if cur_router.is_replacing() {
|
|
||||||
cur_router.remove_previous_routes();
|
|
||||||
}
|
|
||||||
switching_occured = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
NavAction::Dragging => {}
|
|
||||||
NavAction::Returning => {}
|
|
||||||
NavAction::Resetting => {}
|
|
||||||
NavAction::Navigating => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switching_occured
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn process_nav_resp(
|
||||||
|
app: &mut Damus,
|
||||||
|
ctx: &mut AppContext<'_>,
|
||||||
|
ui: &mut egui::Ui,
|
||||||
|
response: NavResponse<Option<RenderNavAction>>,
|
||||||
|
col: usize,
|
||||||
|
) -> bool {
|
||||||
|
let mut switching_occured: bool = false;
|
||||||
|
|
||||||
|
if let Some(action) = response.response.or(response.title_response) {
|
||||||
|
// start returning when we're finished posting
|
||||||
|
|
||||||
|
switching_occured = process_render_nav_action(app, ctx, ui, col, action);
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(action) = response.action {
|
||||||
|
match action {
|
||||||
|
NavAction::Returned => {
|
||||||
|
let r = app
|
||||||
|
.columns_mut(ctx.accounts)
|
||||||
|
.column_mut(col)
|
||||||
|
.router_mut()
|
||||||
|
.pop();
|
||||||
|
|
||||||
|
if let Some(Route::Timeline(kind)) = &r {
|
||||||
|
if let Err(err) = app.timeline_cache.pop(kind, ctx.ndb, ctx.pool) {
|
||||||
|
error!("popping timeline had an error: {err} for {:?}", kind);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
switching_occured = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
NavAction::Navigated => {
|
||||||
|
let cur_router = app.columns_mut(ctx.accounts).column_mut(col).router_mut();
|
||||||
|
cur_router.navigating = false;
|
||||||
|
if cur_router.is_replacing() {
|
||||||
|
cur_router.remove_previous_routes();
|
||||||
|
}
|
||||||
|
switching_occured = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
NavAction::Dragging => {}
|
||||||
|
NavAction::Returning => {}
|
||||||
|
NavAction::Resetting => {}
|
||||||
|
NavAction::Navigating => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switching_occured
|
||||||
|
}
|
||||||
|
|
||||||
fn process_render_nav_action(
|
fn process_render_nav_action(
|
||||||
app: &mut Damus,
|
app: &mut Damus,
|
||||||
ctx: &mut AppContext<'_>,
|
ctx: &mut AppContext<'_>,
|
||||||
|
|||||||
Reference in New Issue
Block a user