refactor: collapse client label settings; drop CLI/settings toggles
The "top vs bottom" client label setting was cluttering the UI and
codebase with toggles that added little value. This consolidates client
label handling into one option, removes unused CLI/settings knobs, and
makes NoteView’s API consistent and fluent. Result: fewer knobs, less
branching, and a clearer, more predictable UI.
Now client labels are only shown in one place: selected notes.
- Drop `--show-client` arg in notedeck and `--show-note-client=top|bottom`
args in notedeck_columns
- Remove `NotedeckOptions::ShowClient` and related CLI parsing
- Delete `ShowSourceClientOption` enum, settings UI, and
`SettingsAction::SetShowSourceClient`
- Collapse `NoteOptions::{ClientNameTop, ClientNameBottom}` into a single
`NoteOptions::ClientName`
- Add `NoteOptions::{Framed, UnreadIndicator}`
- Move “framed” and unread indicator into flags (no more ad‑hoc bools)
- Add new NoteView builder methods: `.client_name()`, `.frame()`,
`.unread_indicator()`, and `.selected_style()`
- CLI flags for showing client labels have been removed
- `ClientNameTop`/`ClientNameBottom` replaced with `ClientName`
- API using `framed` or `show_unread_indicator` booleans must now use
the new flag setters
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -10,7 +10,7 @@ use crate::{
|
||||
subscriptions::{SubKind, Subscriptions},
|
||||
support::Support,
|
||||
timeline::{self, kind::ListKind, thread::Threads, TimelineCache, TimelineKind},
|
||||
ui::{self, DesktopSidePanel, ShowSourceClientOption, SidePanelAction},
|
||||
ui::{self, DesktopSidePanel, SidePanelAction},
|
||||
view_state::ViewState,
|
||||
Result,
|
||||
};
|
||||
@@ -591,17 +591,6 @@ fn get_note_options(args: ColumnsArgs, settings_handler: &mut SettingsHandler) -
|
||||
NoteOptions::HideMedia,
|
||||
args.is_flag_set(ColumnsFlag::NoMedia),
|
||||
);
|
||||
note_options.set(
|
||||
NoteOptions::ClientNameTop,
|
||||
ShowSourceClientOption::Top == settings_handler.show_source_client().into()
|
||||
|| args.is_flag_set(ColumnsFlag::ShowNoteClientTop),
|
||||
);
|
||||
note_options.set(
|
||||
NoteOptions::ClientNameBottom,
|
||||
ShowSourceClientOption::Bottom == settings_handler.show_source_client().into()
|
||||
|| args.is_flag_set(ColumnsFlag::ShowNoteClientBottom),
|
||||
);
|
||||
|
||||
note_options.set(
|
||||
NoteOptions::RepliesNewestFirst,
|
||||
settings_handler.show_replies_newest_first(),
|
||||
|
||||
@@ -11,8 +11,6 @@ pub enum ColumnsFlag {
|
||||
Textmode,
|
||||
Scramble,
|
||||
NoMedia,
|
||||
ShowNoteClientTop,
|
||||
ShowNoteClientBottom,
|
||||
}
|
||||
|
||||
pub struct ColumnsArgs {
|
||||
@@ -54,10 +52,6 @@ impl ColumnsArgs {
|
||||
res.clear_flag(ColumnsFlag::SinceOptimize);
|
||||
} else if arg == "--scramble" {
|
||||
res.set_flag(ColumnsFlag::Scramble);
|
||||
} else if arg == "--show-note-client=top" {
|
||||
res.set_flag(ColumnsFlag::ShowNoteClientTop);
|
||||
} else if arg == "--show-note-client=bottom" {
|
||||
res.set_flag(ColumnsFlag::ShowNoteClientBottom);
|
||||
} else if arg == "--no-media" {
|
||||
res.set_flag(ColumnsFlag::NoMedia);
|
||||
} else if arg == "--filter" {
|
||||
|
||||
@@ -26,7 +26,6 @@ pub use preview::{Preview, PreviewApp, PreviewConfig};
|
||||
pub use profile::ProfileView;
|
||||
pub use relay::RelayView;
|
||||
pub use settings::SettingsView;
|
||||
pub use settings::ShowSourceClientOption;
|
||||
pub use side_panel::{DesktopSidePanel, SidePanelAction};
|
||||
pub use thread::ThreadView;
|
||||
pub use timeline::TimelineView;
|
||||
|
||||
@@ -10,7 +10,6 @@ use notedeck::{
|
||||
SettingsHandler, DEFAULT_NOTE_BODY_FONT_SIZE,
|
||||
};
|
||||
use notedeck_ui::{NoteOptions, NoteView};
|
||||
use strum::Display;
|
||||
|
||||
use crate::{nav::RouterAction, Damus, Route};
|
||||
|
||||
@@ -21,89 +20,9 @@ const MAX_ZOOM: f32 = 3.0;
|
||||
const ZOOM_STEP: f32 = 0.1;
|
||||
const RESET_ZOOM: f32 = 1.0;
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Display)]
|
||||
pub enum ShowSourceClientOption {
|
||||
Hide,
|
||||
Top,
|
||||
Bottom,
|
||||
}
|
||||
|
||||
impl From<ShowSourceClientOption> for String {
|
||||
fn from(show_option: ShowSourceClientOption) -> Self {
|
||||
match show_option {
|
||||
ShowSourceClientOption::Hide => "hide".to_string(),
|
||||
ShowSourceClientOption::Top => "top".to_string(),
|
||||
ShowSourceClientOption::Bottom => "bottom".to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<NoteOptions> for ShowSourceClientOption {
|
||||
fn from(note_options: NoteOptions) -> Self {
|
||||
if note_options.contains(NoteOptions::ClientNameTop) {
|
||||
ShowSourceClientOption::Top
|
||||
} else if note_options.contains(NoteOptions::ClientNameBottom) {
|
||||
ShowSourceClientOption::Bottom
|
||||
} else {
|
||||
ShowSourceClientOption::Hide
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<String> for ShowSourceClientOption {
|
||||
fn from(s: String) -> Self {
|
||||
match s.to_lowercase().as_str() {
|
||||
"hide" => Self::Hide,
|
||||
"top" => Self::Top,
|
||||
"bottom" => Self::Bottom,
|
||||
_ => Self::Hide, // default fallback
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ShowSourceClientOption {
|
||||
pub fn set_note_options(self, note_options: &mut NoteOptions) {
|
||||
match self {
|
||||
Self::Hide => {
|
||||
note_options.set(NoteOptions::ClientNameTop, false);
|
||||
note_options.set(NoteOptions::ClientNameBottom, false);
|
||||
}
|
||||
Self::Bottom => {
|
||||
note_options.set(NoteOptions::ClientNameTop, false);
|
||||
note_options.set(NoteOptions::ClientNameBottom, true);
|
||||
}
|
||||
Self::Top => {
|
||||
note_options.set(NoteOptions::ClientNameTop, true);
|
||||
note_options.set(NoteOptions::ClientNameBottom, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn label(&self, i18n: &mut Localization) -> String {
|
||||
match self {
|
||||
Self::Hide => tr!(
|
||||
i18n,
|
||||
"Hide",
|
||||
"Option in settings section to hide the source client label in note display"
|
||||
),
|
||||
Self::Top => tr!(
|
||||
i18n,
|
||||
"Top",
|
||||
"Option in settings section to show the source client label at the top of the note"
|
||||
),
|
||||
Self::Bottom => tr!(
|
||||
i18n,
|
||||
"Bottom",
|
||||
"Option in settings section to show the source client label at the bottom of the note"
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub enum SettingsAction {
|
||||
SetZoomFactor(f32),
|
||||
SetTheme(ThemePreference),
|
||||
SetShowSourceClient(ShowSourceClientOption),
|
||||
SetLocale(LanguageIdentifier),
|
||||
SetRepliestNewestFirst(bool),
|
||||
SetNoteBodyFontSize(f32),
|
||||
@@ -131,11 +50,6 @@ impl SettingsAction {
|
||||
ctx.set_zoom_factor(zoom_factor);
|
||||
settings.set_zoom_factor(zoom_factor);
|
||||
}
|
||||
Self::SetShowSourceClient(option) => {
|
||||
option.set_note_options(&mut app.note_options);
|
||||
|
||||
settings.set_show_source_client(option);
|
||||
}
|
||||
Self::SetTheme(theme) => {
|
||||
ctx.set_theme(theme);
|
||||
settings.set_theme(theme);
|
||||
@@ -551,35 +465,6 @@ impl<'a> SettingsView<'a> {
|
||||
));
|
||||
}
|
||||
});
|
||||
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
ui.label(richtext_small(tr!(
|
||||
self.note_context.i18n,
|
||||
"Source client:",
|
||||
"Label for Source client, others settings section",
|
||||
)));
|
||||
|
||||
for option in [
|
||||
ShowSourceClientOption::Hide,
|
||||
ShowSourceClientOption::Top,
|
||||
ShowSourceClientOption::Bottom,
|
||||
] {
|
||||
let mut current: ShowSourceClientOption =
|
||||
self.settings.show_source_client.clone().into();
|
||||
|
||||
if ui
|
||||
.selectable_value(
|
||||
&mut current,
|
||||
option,
|
||||
RichText::new(option.label(self.note_context.i18n))
|
||||
.text_style(NotedeckTextStyle::Small.text_style()),
|
||||
)
|
||||
.changed()
|
||||
{
|
||||
action = Some(SettingsAction::SetShowSourceClient(option));
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
action
|
||||
|
||||
@@ -279,6 +279,12 @@ enum ThreadNoteType {
|
||||
Reply,
|
||||
}
|
||||
|
||||
impl ThreadNoteType {
|
||||
fn is_selected(&self) -> bool {
|
||||
matches!(self, ThreadNoteType::Selected { .. })
|
||||
}
|
||||
}
|
||||
|
||||
struct ThreadNotes<'a> {
|
||||
notes: Vec<ThreadNote<'a>>,
|
||||
selected_index: usize,
|
||||
@@ -313,6 +319,7 @@ impl<'a> ThreadNote<'a> {
|
||||
) -> NoteResponse {
|
||||
let inner = notedeck_ui::padding(8.0, ui, |ui| {
|
||||
NoteView::new(note_context, &self.note, self.options(flags), jobs)
|
||||
.selected_style(self.note_type.is_selected())
|
||||
.unread_indicator(self.unread_and_have_replies)
|
||||
.show(ui)
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user