Skip to content

Commit

Permalink
persistent: dont nuke decks when using cli columns
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jb55 committed Jan 17, 2025
1 parent e4732f5 commit b45a63a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion crates/notedeck_columns/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -424,6 +427,7 @@ impl Damus {
textmode: parsed_args.textmode,
//frame_history: FrameHistory::default(),
view_state: ViewState::default(),
tmp_columns,
support,
decks_cache,
debug,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit b45a63a

Please sign in to comment.