nav: only save columns once
Before we would save columns for each rendered nav. Now we only do it once.
This commit is contained in:
14
src/app.rs
14
src/app.rs
@@ -744,8 +744,10 @@ fn render_damus_mobile(ctx: &egui::Context, app: &mut Damus) {
|
|||||||
//let routes = app.timelines[0].routes.clone();
|
//let routes = app.timelines[0].routes.clone();
|
||||||
|
|
||||||
main_panel(&ctx.style(), ui::is_narrow(ctx)).show(ctx, |ui| {
|
main_panel(&ctx.style(), ui::is_narrow(ctx)).show(ctx, |ui| {
|
||||||
if !app.columns.columns().is_empty() {
|
if !app.columns.columns().is_empty()
|
||||||
nav::render_nav(0, app, ui).process_render_nav_response(app);
|
&& 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());
|
let mut responses = Vec::with_capacity(app.columns.num_columns());
|
||||||
for col_index in 0..app.columns.num_columns() {
|
for col_index in 0..app.columns.num_columns() {
|
||||||
strip.cell(|ui| {
|
strip.cell(|ui| {
|
||||||
@@ -840,7 +843,12 @@ fn timelines_view(ui: &mut egui::Ui, sizes: Size, app: &mut Damus) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for response in responses {
|
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());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ use crate::{
|
|||||||
profile::Profile,
|
profile::Profile,
|
||||||
relay_pool_manager::RelayPoolManager,
|
relay_pool_manager::RelayPoolManager,
|
||||||
route::Route,
|
route::Route,
|
||||||
storage::{self},
|
|
||||||
thread::Thread,
|
thread::Thread,
|
||||||
timeline::{
|
timeline::{
|
||||||
route::{render_timeline_route, TimelineRoute},
|
route::{render_timeline_route, TimelineRoute},
|
||||||
@@ -60,7 +59,8 @@ impl RenderNavResponse {
|
|||||||
RenderNavResponse { column, response }
|
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 mut col_changed: bool = false;
|
||||||
let col = self.column;
|
let col = self.column;
|
||||||
|
|
||||||
@@ -146,9 +146,7 @@ impl RenderNavResponse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if col_changed {
|
col_changed
|
||||||
storage::save_columns(&app.path, app.columns().as_serializable_columns());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user