Skip to content

Commit

Permalink
feat: add --no-media flag to disable media display
Browse files Browse the repository at this point in the history
- Introduced a new "no_media" boolean in ColumnsArgs to capture the
  --no-media flag.

- Updated NoteOptions to include a setting for hiding media, configured
  from parsed arguments.

- Refactored Damus to consolidate note options (textmode, scramble, and
  no-media) into a single NoteOptions field.

- Modified navigation UI rendering to pass the unified note_options.

This change allows users to disable media display via the --no-media flag.

Signed-off-by: William Casarin <[email protected]>
  • Loading branch information
jb55 committed Feb 22, 2025
1 parent bd352f7 commit 660b7cc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
17 changes: 8 additions & 9 deletions crates/notedeck_columns/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
subscriptions::{SubKind, Subscriptions},
support::Support,
timeline::{self, TimelineCache},
ui::{self, DesktopSidePanel},
ui::{self, note::NoteOptions, DesktopSidePanel},
unknowns,
view_state::ViewState,
Result,
Expand Down Expand Up @@ -50,10 +50,7 @@ pub struct Damus {
pub tmp_columns: bool,
pub debug: bool,
pub since_optimize: bool,
pub textmode: bool,

/// Scramble text for development
pub scramble: bool,
pub note_options: NoteOptions,

pub unrecognized_args: BTreeSet<String>,
}
Expand Down Expand Up @@ -425,15 +422,18 @@ impl Damus {

let debug = ctx.args.debug;
let support = Support::new(ctx.path);
let mut note_options = NoteOptions::default();
note_options.set_textmode(parsed_args.textmode);
note_options.set_scramble_text(parsed_args.scramble);
note_options.set_hide_media(parsed_args.no_media);

Self {
subscriptions: Subscriptions::default(),
since_optimize: parsed_args.since_optimize,
timeline_cache,
drafts: Drafts::default(),
state: DamusState::Initializing,
textmode: parsed_args.textmode,
scramble: parsed_args.scramble,
note_options,
//frame_history: FrameHistory::default(),
view_state: ViewState::default(),
tmp_columns,
Expand Down Expand Up @@ -477,8 +477,7 @@ impl Damus {
timeline_cache: TimelineCache::default(),
drafts: Drafts::default(),
state: DamusState::Initializing,
textmode: false,
scramble: false,
note_options: NoteOptions::default(),
tmp_columns: true,
//frame_history: FrameHistory::default(),
view_state: ViewState::default(),
Expand Down
4 changes: 4 additions & 0 deletions crates/notedeck_columns/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub struct ColumnsArgs {
pub since_optimize: bool,
pub textmode: bool,
pub scramble: bool,
pub no_media: bool,
}

impl ColumnsArgs {
Expand All @@ -19,6 +20,7 @@ impl ColumnsArgs {
since_optimize: true,
textmode: false,
scramble: false,
no_media: false,
};

let mut i = 0;
Expand All @@ -32,6 +34,8 @@ impl ColumnsArgs {
res.since_optimize = false;
} else if arg == "--scramble" {
res.scramble = true;
} else if arg == "--no-media" {
res.no_media = true;
} else if arg == "--filter" {
i += 1;
let filter = if let Some(next_arg) = args.get(i) {
Expand Down
17 changes: 5 additions & 12 deletions crates/notedeck_columns/src/nav.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::{
column::NavTitle,
configure_deck::ConfigureDeckView,
edit_deck::{EditDeckResponse, EditDeckView},
note::{NoteOptions, PostAction, PostType},
note::{PostAction, PostType},
profile::EditProfileView,
support::SupportView,
RelayView, View,
Expand Down Expand Up @@ -243,13 +243,6 @@ fn render_nav_body(
col: usize,
inner_rect: egui::Rect,
) -> Option<RenderNavAction> {
let note_options = {
let mut options = NoteOptions::default();
options.set_textmode(app.textmode);
options.set_scramble_text(app.scramble);
options
};

match top {
Route::Timeline(kind) => render_timeline_route(
ctx.ndb,
Expand All @@ -260,7 +253,7 @@ fn render_nav_body(
ctx.accounts,
kind,
col,
note_options,
app.note_options,
depth,
ui,
),
Expand Down Expand Up @@ -317,7 +310,7 @@ fn render_nav_body(
ctx.img_cache,
&note,
inner_rect,
note_options,
app.note_options,
)
.id_source(id)
.show(ui)
Expand Down Expand Up @@ -353,7 +346,7 @@ fn render_nav_body(
draft,
&note,
inner_rect,
note_options,
app.note_options,
)
.id_source(id)
.show(ui)
Expand All @@ -375,7 +368,7 @@ fn render_nav_body(
ctx.note_cache,
kp,
inner_rect,
note_options,
app.note_options,
)
.ui(&txn, ui);

Expand Down

0 comments on commit 660b7cc

Please sign in to comment.