make clippy happy

This commit is contained in:
William Casarin
2025-07-31 11:55:39 -07:00
parent a896a6ecfa
commit a8c6baeacb
5 changed files with 31 additions and 19 deletions

View File

@@ -1,8 +1,6 @@
use crate::NotedeckTextStyle; use crate::NotedeckTextStyle;
pub const NARROW_SCREEN_WIDTH: f32 = 550.0; 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 pub fn richtext_small<S>(text: S) -> egui::RichText
where where
@@ -11,6 +9,8 @@ where
egui::RichText::new(text).text_style(NotedeckTextStyle::Small.text_style()) 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 { pub fn is_narrow(ctx: &egui::Context) -> bool {
let screen_size = ctx.input(|c| c.screen_rect().size()); let screen_size = ctx.input(|c| c.screen_rect().size());
screen_size.x < NARROW_SCREEN_WIDTH screen_size.x < NARROW_SCREEN_WIDTH

View File

@@ -582,7 +582,7 @@ fn render_nav_body(
.map(RenderNavAction::RelayAction), .map(RenderNavAction::RelayAction),
Route::Settings => SettingsView::new( Route::Settings => SettingsView::new(
&mut ctx.settings.get_settings_mut(), ctx.settings.get_settings_mut(),
&mut note_context, &mut note_context,
&mut app.note_options, &mut app.note_options,
&mut app.jobs, &mut app.jobs,

View File

@@ -31,12 +31,12 @@ pub enum ShowSourceClientOption {
Bottom, Bottom,
} }
impl Into<String> for ShowSourceClientOption { impl From<ShowSourceClientOption> for String {
fn into(self) -> String { fn from(show_option: ShowSourceClientOption) -> Self {
match self { match show_option {
Self::Hide => "hide".to_string(), ShowSourceClientOption::Hide => "hide".to_string(),
Self::Top => "top".to_string(), ShowSourceClientOption::Top => "top".to_string(),
Self::Bottom => "bottom".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 { match self {
Self::Hide => tr!(i18n, "Hide", "Option in settings section to hide the source client label in note display"), Self::Hide => tr!(
Self::Top => tr!(i18n, "Top", "Option in settings section to show the source client label at the top of the note"), i18n,
Self::Bottom => tr!(i18n, "Bottom", "Option in settings section to show the source client label at the bottom of the note"), "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(); let txn = Transaction::new(self.note_context.ndb).unwrap();
if let Some(note_id) = NoteId::from_bech(PREVIEW_NOTE_ID) { if let Some(note_id) = NoteId::from_bech(PREVIEW_NOTE_ID) {
if let Ok(preview_note) = 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| { notedeck_ui::padding(8.0, ui, |ui| {
if is_narrow(ui.ctx()) { if is_narrow(ui.ctx()) {
@@ -270,7 +282,7 @@ impl<'a> SettingsView<'a> {
NoteView::new( NoteView::new(
self.note_context, self.note_context,
&preview_note, &preview_note,
self.note_options.clone(), *self.note_options,
self.jobs, self.jobs,
) )
.actionbar(false) .actionbar(false)

View File

@@ -255,7 +255,7 @@ impl<'a> ThreadNoteBuilder<'a> {
if replies_newer_first { if replies_newer_first {
self.replies 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 { for reply in self.replies {

View File

@@ -211,7 +211,7 @@ pub fn render_note_contents<'a>(
}, },
BlockType::Hashtag => { BlockType::Hashtag => {
if block.as_str().trim().len() == 0 { if block.as_str().trim().is_empty() {
continue 'block_loop; continue 'block_loop;
} }
let resp = ui let resp = ui
@@ -244,7 +244,7 @@ pub fn render_note_contents<'a>(
}; };
if hide_media || !found_supported() { if hide_media || !found_supported() {
if block.as_str().trim().len() == 0 { if block.as_str().trim().is_empty() {
continue 'block_loop; continue 'block_loop;
} }
ui.add(Hyperlink::from_label_and_url( ui.add(Hyperlink::from_label_and_url(
@@ -276,7 +276,7 @@ pub fn render_note_contents<'a>(
current_len += block_str.len(); current_len += block_str.len();
block_str block_str
}; };
if block_str.trim().len() == 0 { if block_str.trim().is_empty() {
continue 'block_loop; continue 'block_loop;
} }
if options.contains(NoteOptions::ScrambleText) { if options.contains(NoteOptions::ScrambleText) {