feat: add --no-media flag to disable media display

- 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 <jb55@jb55.com>
This commit is contained in:
William Casarin
2025-02-22 14:39:04 -08:00
parent bd352f76d4
commit 660b7cc8b7
3 changed files with 17 additions and 21 deletions

View File

@@ -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,
@@ -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>,
}
@@ -425,6 +422,10 @@ 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(),
@@ -432,8 +433,7 @@ impl Damus {
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,
@@ -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(),

View File

@@ -9,6 +9,7 @@ pub struct ColumnsArgs {
pub since_optimize: bool,
pub textmode: bool,
pub scramble: bool,
pub no_media: bool,
}
impl ColumnsArgs {
@@ -19,6 +20,7 @@ impl ColumnsArgs {
since_optimize: true,
textmode: false,
scramble: false,
no_media: false,
};
let mut i = 0;
@@ -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) {

View File

@@ -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,
@@ -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,
@@ -260,7 +253,7 @@ fn render_nav_body(
ctx.accounts,
kind,
col,
note_options,
app.note_options,
depth,
ui,
),
@@ -317,7 +310,7 @@ fn render_nav_body(
ctx.img_cache,
&note,
inner_rect,
note_options,
app.note_options,
)
.id_source(id)
.show(ui)
@@ -353,7 +346,7 @@ fn render_nav_body(
draft,
&note,
inner_rect,
note_options,
app.note_options,
)
.id_source(id)
.show(ui)
@@ -375,7 +368,7 @@ fn render_nav_body(
ctx.note_cache,
kp,
inner_rect,
note_options,
app.note_options,
)
.ui(&txn, ui);