From b45a63a529c73bbb89130463905da10c03919bfb Mon Sep 17 00:00:00 2001 From: William Casarin Date: Fri, 17 Jan 2025 09:32:48 -0800 Subject: [PATCH] persistent: dont nuke decks when using cli columns Sometimes the commandline is nice for loading individual threads you want to lookup (we don't have a UI for this yet). If you don't currently choose a different data directory, then your decks cache gets nuked when doing this. Change the logic so that deck persistence is disabled when using CLI columns. This stops notedeck from nuking your default decks. Signed-off-by: William Casarin --- crates/notedeck_columns/src/app.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/notedeck_columns/src/app.rs b/crates/notedeck_columns/src/app.rs index 5976f190..46c27943 100644 --- a/crates/notedeck_columns/src/app.rs +++ b/crates/notedeck_columns/src/app.rs @@ -51,6 +51,8 @@ pub struct Damus { //frame_history: crate::frame_history::FrameHistory, // TODO: make these bitflags + /// Were columns loaded from the commandline? If so disable persistence. + pub tmp_columns: bool, pub debug: bool, pub since_optimize: bool, pub textmode: bool, @@ -378,7 +380,8 @@ impl Damus { .as_ref() .map(|a| a.pubkey.bytes()); - let decks_cache = if !parsed_args.columns.is_empty() { + let tmp_columns = !parsed_args.columns.is_empty(); + let decks_cache = if tmp_columns { info!("DecksCache: loading from command line arguments"); let mut columns: Columns = Columns::new(); for col in parsed_args.columns { @@ -424,6 +427,7 @@ impl Damus { textmode: parsed_args.textmode, //frame_history: FrameHistory::default(), view_state: ViewState::default(), + tmp_columns, support, decks_cache, debug, @@ -465,6 +469,7 @@ impl Damus { drafts: Drafts::default(), state: DamusState::Initializing, textmode: false, + tmp_columns: true, //frame_history: FrameHistory::default(), view_state: ViewState::default(), support, @@ -502,6 +507,7 @@ fn render_damus_mobile(app: &mut Damus, app_ctx: &mut AppContext<'_>, ui: &mut e if !app.columns(app_ctx.accounts).columns().is_empty() && nav::render_nav(0, app, app_ctx, ui).process_render_nav_response(app, app_ctx) + && !app.tmp_columns { storage::save_decks_cache(app_ctx.path, &app.decks_cache); } @@ -601,6 +607,10 @@ fn timelines_view(ui: &mut egui::Ui, sizes: Size, app: &mut Damus, ctx: &mut App save_cols = save_cols || save; } + if app.tmp_columns { + save_cols = false; + } + if save_cols { storage::save_decks_cache(ctx.path, &app.decks_cache); }