notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit a8c6baeacb8247f1f2eb5f6690efdcdafde90624
parent a896a6ecfa12b0af6b7f4fe6337a0dd93bb1f139
Author: William Casarin <jb55@jb55.com>
Date:   Thu, 31 Jul 2025 11:55:39 -0700

make clippy happy

Diffstat:
Mcrates/notedeck/src/ui.rs | 4++--
Mcrates/notedeck_columns/src/nav.rs | 2+-
Mcrates/notedeck_columns/src/ui/settings.rs | 36++++++++++++++++++++++++------------
Mcrates/notedeck_columns/src/ui/thread.rs | 2+-
Mcrates/notedeck_ui/src/note/contents.rs | 6+++---
5 files changed, 31 insertions(+), 19 deletions(-)

diff --git a/crates/notedeck/src/ui.rs b/crates/notedeck/src/ui.rs @@ -1,8 +1,6 @@ use crate::NotedeckTextStyle; pub const NARROW_SCREEN_WIDTH: f32 = 550.0; -/// Determine if the screen is narrow. This is useful for detecting mobile -/// contexts, but with the nuance that we may also have a wide android tablet. pub fn richtext_small<S>(text: S) -> egui::RichText where @@ -11,6 +9,8 @@ where egui::RichText::new(text).text_style(NotedeckTextStyle::Small.text_style()) } +/// Determine if the screen is narrow. This is useful for detecting mobile +/// contexts, but with the nuance that we may also have a wide android tablet. pub fn is_narrow(ctx: &egui::Context) -> bool { let screen_size = ctx.input(|c| c.screen_rect().size()); screen_size.x < NARROW_SCREEN_WIDTH diff --git a/crates/notedeck_columns/src/nav.rs b/crates/notedeck_columns/src/nav.rs @@ -582,7 +582,7 @@ fn render_nav_body( .map(RenderNavAction::RelayAction), Route::Settings => SettingsView::new( - &mut ctx.settings.get_settings_mut(), + ctx.settings.get_settings_mut(), &mut note_context, &mut app.note_options, &mut app.jobs, diff --git a/crates/notedeck_columns/src/ui/settings.rs b/crates/notedeck_columns/src/ui/settings.rs @@ -31,12 +31,12 @@ pub enum ShowSourceClientOption { Bottom, } -impl Into<String> for ShowSourceClientOption { - fn into(self) -> String { - match self { - Self::Hide => "hide".to_string(), - Self::Top => "top".to_string(), - Self::Bottom => "bottom".to_string(), +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(), } } } @@ -82,11 +82,23 @@ impl ShowSourceClientOption { } } - fn label<'a>(&self, i18n: &'a mut Localization) -> String { + 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"), + 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" + ), } } } @@ -260,7 +272,7 @@ impl<'a> SettingsView<'a> { let txn = Transaction::new(self.note_context.ndb).unwrap(); if let Some(note_id) = NoteId::from_bech(PREVIEW_NOTE_ID) { if let Ok(preview_note) = - self.note_context.ndb.get_note_by_id(&txn, &note_id.bytes()) + self.note_context.ndb.get_note_by_id(&txn, note_id.bytes()) { notedeck_ui::padding(8.0, ui, |ui| { if is_narrow(ui.ctx()) { @@ -270,7 +282,7 @@ impl<'a> SettingsView<'a> { NoteView::new( self.note_context, &preview_note, - self.note_options.clone(), + *self.note_options, self.jobs, ) .actionbar(false) diff --git a/crates/notedeck_columns/src/ui/thread.rs b/crates/notedeck_columns/src/ui/thread.rs @@ -255,7 +255,7 @@ impl<'a> ThreadNoteBuilder<'a> { if replies_newer_first { self.replies - .sort_by(|a, b| b.created_at().cmp(&a.created_at())); + .sort_by_key(|b| std::cmp::Reverse(b.created_at())); } for reply in self.replies { diff --git a/crates/notedeck_ui/src/note/contents.rs b/crates/notedeck_ui/src/note/contents.rs @@ -211,7 +211,7 @@ pub fn render_note_contents<'a>( }, BlockType::Hashtag => { - if block.as_str().trim().len() == 0 { + if block.as_str().trim().is_empty() { continue 'block_loop; } let resp = ui @@ -244,7 +244,7 @@ pub fn render_note_contents<'a>( }; if hide_media || !found_supported() { - if block.as_str().trim().len() == 0 { + if block.as_str().trim().is_empty() { continue 'block_loop; } ui.add(Hyperlink::from_label_and_url( @@ -276,7 +276,7 @@ pub fn render_note_contents<'a>( current_len += block_str.len(); block_str }; - if block_str.trim().len() == 0 { + if block_str.trim().is_empty() { continue 'block_loop; } if options.contains(NoteOptions::ScrambleText) {