notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit 679a5afdebbb446552041526f3be740c4c84e128
parent 7f234935cc537780574fa0d6821998aee64dc6dd
Author: William Casarin <jb55@jb55.com>
Date:   Tue, 19 Nov 2024 18:51:01 -0800

nav: only save columns once

Before we would save columns for each rendered nav. Now we only do it
once.

Diffstat:
Msrc/app.rs | 14+++++++++++---
Msrc/nav.rs | 8+++-----
2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/app.rs b/src/app.rs @@ -744,8 +744,10 @@ fn render_damus_mobile(ctx: &egui::Context, app: &mut Damus) { //let routes = app.timelines[0].routes.clone(); main_panel(&ctx.style(), ui::is_narrow(ctx)).show(ctx, |ui| { - if !app.columns.columns().is_empty() { - nav::render_nav(0, app, ui).process_render_nav_response(app); + if !app.columns.columns().is_empty() + && nav::render_nav(0, app, ui).process_render_nav_response(app) + { + storage::save_columns(&app.path, app.columns().as_serializable_columns()); } }); } @@ -822,6 +824,7 @@ fn timelines_view(ui: &mut egui::Ui, sizes: Size, app: &mut Damus) { ); }); + let mut save_cols = false; let mut responses = Vec::with_capacity(app.columns.num_columns()); for col_index in 0..app.columns.num_columns() { strip.cell(|ui| { @@ -840,7 +843,12 @@ fn timelines_view(ui: &mut egui::Ui, sizes: Size, app: &mut Damus) { } for response in responses { - response.process_render_nav_response(app); + let save = response.process_render_nav_response(app); + save_cols = save_cols || save; + } + + if save_cols { + storage::save_columns(&app.path, app.columns().as_serializable_columns()); } }); } diff --git a/src/nav.rs b/src/nav.rs @@ -7,7 +7,6 @@ use crate::{ profile::Profile, relay_pool_manager::RelayPoolManager, route::Route, - storage::{self}, thread::Thread, timeline::{ route::{render_timeline_route, TimelineRoute}, @@ -60,7 +59,8 @@ impl RenderNavResponse { RenderNavResponse { column, response } } - pub fn process_render_nav_response(&self, app: &mut Damus) { + #[must_use = "Make sure to save columns if result is true"] + pub fn process_render_nav_response(&self, app: &mut Damus) -> bool { let mut col_changed: bool = false; let col = self.column; @@ -146,9 +146,7 @@ impl RenderNavResponse { } } - if col_changed { - storage::save_columns(&app.path, app.columns().as_serializable_columns()); - } + col_changed } }