From cec49c83bd4f17b074bcb0b2479630c15069c2bc Mon Sep 17 00:00:00 2001 From: William Casarin Date: Fri, 7 Mar 2025 12:36:26 -0800 Subject: [PATCH] fix formatting Signed-off-by: William Casarin --- crates/notedeck_columns/src/nav.rs | 3 +- crates/notedeck_columns/src/timeline/route.rs | 3 +- .../notedeck_columns/src/ui/note/contents.rs | 24 ++++-- crates/notedeck_columns/src/ui/note/mod.rs | 4 +- crates/notedeck_columns/src/ui/note/post.rs | 9 ++- .../src/ui/note/reply_description.rs | 78 ++++++++++++------- crates/notedeck_columns/src/ui/profile/mod.rs | 9 ++- crates/notedeck_columns/src/ui/timeline.rs | 22 ++++-- 8 files changed, 100 insertions(+), 52 deletions(-) diff --git a/crates/notedeck_columns/src/nav.rs b/crates/notedeck_columns/src/nav.rs index 6606eab..13826d1 100644 --- a/crates/notedeck_columns/src/nav.rs +++ b/crates/notedeck_columns/src/nav.rs @@ -352,7 +352,8 @@ fn render_nav_body( let txn = Transaction::new(ctx.ndb).expect("txn"); let post_response = - ui::PostView::new(&mut note_context, draft, PostType::New, kp, inner_rect).ui(&txn, ui); + ui::PostView::new(&mut note_context, draft, PostType::New, kp, inner_rect) + .ui(&txn, ui); post_response.action.map(Into::into) } diff --git a/crates/notedeck_columns/src/timeline/route.rs b/crates/notedeck_columns/src/timeline/route.rs index f601e99..cc75c53 100644 --- a/crates/notedeck_columns/src/timeline/route.rs +++ b/crates/notedeck_columns/src/timeline/route.rs @@ -31,7 +31,8 @@ pub fn render_timeline_route( | TimelineKind::Hashtag(_) | TimelineKind::Generic(_) => { let note_action = - ui::TimelineView::new(kind, timeline_cache, &accounts.mutefun(), note_context).ui(ui); + ui::TimelineView::new(kind, timeline_cache, &accounts.mutefun(), note_context) + .ui(ui); note_action.map(RenderNavAction::NoteAction) } diff --git a/crates/notedeck_columns/src/ui/note/contents.rs b/crates/notedeck_columns/src/ui/note/contents.rs index a0458fa..11db67c 100644 --- a/crates/notedeck_columns/src/ui/note/contents.rs +++ b/crates/notedeck_columns/src/ui/note/contents.rs @@ -146,20 +146,28 @@ fn render_note_contents( match block.blocktype() { BlockType::MentionBech32 => match block.as_mention().unwrap() { Mention::Profile(profile) => { - let act = - ui::Mention::new(note_context.ndb, note_context.img_cache, txn, profile.pubkey()) - .show(ui) - .inner; + let act = ui::Mention::new( + note_context.ndb, + note_context.img_cache, + txn, + profile.pubkey(), + ) + .show(ui) + .inner; if act.is_some() { note_action = act; } } Mention::Pubkey(npub) => { - let act = - ui::Mention::new(note_context.ndb, note_context.img_cache, txn, npub.pubkey()) - .show(ui) - .inner; + let act = ui::Mention::new( + note_context.ndb, + note_context.img_cache, + txn, + npub.pubkey(), + ) + .show(ui) + .inner; if act.is_some() { note_action = act; } diff --git a/crates/notedeck_columns/src/ui/note/mod.rs b/crates/notedeck_columns/src/ui/note/mod.rs index 54e56a3..eddb239 100644 --- a/crates/notedeck_columns/src/ui/note/mod.rs +++ b/crates/notedeck_columns/src/ui/note/mod.rs @@ -385,7 +385,9 @@ impl<'a, 'd> NoteView<'a, 'd> { if note_reply.reply().is_some() { let action = ui - .horizontal(|ui| reply_desc(ui, txn, ¬e_reply, self.note_context)) + .horizontal(|ui| { + reply_desc(ui, txn, ¬e_reply, self.note_context) + }) .inner; if action.is_some() { diff --git a/crates/notedeck_columns/src/ui/note/post.rs b/crates/notedeck_columns/src/ui/note/post.rs index 2dde84d..0401f22 100644 --- a/crates/notedeck_columns/src/ui/note/post.rs +++ b/crates/notedeck_columns/src/ui/note/post.rs @@ -223,7 +223,8 @@ impl<'a, 'd> PostView<'a, 'd> { hint_rect }; - if let Ok(res) = self.note_context.ndb.search_profile(txn, mention_str, 10) { + if let Ok(res) = self.note_context.ndb.search_profile(txn, mention_str, 10) + { let resp = SearchResultsView::new( self.note_context.img_cache, self.note_context.ndb, @@ -238,8 +239,10 @@ impl<'a, 'd> PostView<'a, 'd> { ) => { if let Some(hint_index) = selection { if let Some(pk) = res.get(hint_index) { - let record = - self.note_context.ndb.get_profile_by_pubkey(txn, pk); + let record = self + .note_context + .ndb + .get_profile_by_pubkey(txn, pk); self.draft.buffer.select_mention_and_replace_name( mention.index, diff --git a/crates/notedeck_columns/src/ui/note/reply_description.rs b/crates/notedeck_columns/src/ui/note/reply_description.rs index a503694..867fbbb 100644 --- a/crates/notedeck_columns/src/ui/note/reply_description.rs +++ b/crates/notedeck_columns/src/ui/note/reply_description.rs @@ -61,11 +61,16 @@ pub fn reply_desc( if note_reply.is_reply_to_root() { // We're replying to the root, let's show this - let action = ui::Mention::new(note_context.ndb, note_context.img_cache, txn, reply_note.pubkey()) - .size(size) - .selectable(selectable) - .show(ui) - .inner; + let action = ui::Mention::new( + note_context.ndb, + note_context.img_cache, + txn, + reply_note.pubkey(), + ) + .size(size) + .selectable(selectable) + .show(ui) + .inner; if action.is_some() { note_action = action; @@ -80,12 +85,16 @@ pub fn reply_desc( if let Ok(root_note) = note_context.ndb.get_note_by_id(txn, root.id) { if root_note.pubkey() == reply_note.pubkey() { // simply "replying to bob's note" when replying to bob in his thread - let action = - ui::Mention::new(note_context.ndb, note_context.img_cache, txn, reply_note.pubkey()) - .size(size) - .selectable(selectable) - .show(ui) - .inner; + let action = ui::Mention::new( + note_context.ndb, + note_context.img_cache, + txn, + reply_note.pubkey(), + ) + .size(size) + .selectable(selectable) + .show(ui) + .inner; if action.is_some() { note_action = action; @@ -99,12 +108,16 @@ pub fn reply_desc( } else { // replying to bob in alice's thread - let action = - ui::Mention::new(note_context.ndb, note_context.img_cache, txn, reply_note.pubkey()) - .size(size) - .selectable(selectable) - .show(ui) - .inner; + let action = ui::Mention::new( + note_context.ndb, + note_context.img_cache, + txn, + reply_note.pubkey(), + ) + .size(size) + .selectable(selectable) + .show(ui) + .inner; if action.is_some() { note_action = action; @@ -120,12 +133,16 @@ pub fn reply_desc( Label::new(RichText::new("in").size(size).color(color)).selectable(selectable), ); - let action = - ui::Mention::new(note_context.ndb, note_context.img_cache, txn, root_note.pubkey()) - .size(size) - .selectable(selectable) - .show(ui) - .inner; + let action = ui::Mention::new( + note_context.ndb, + note_context.img_cache, + txn, + root_note.pubkey(), + ) + .size(size) + .selectable(selectable) + .show(ui) + .inner; if action.is_some() { note_action = action; @@ -138,11 +155,16 @@ pub fn reply_desc( note_link(ui, note_context, "thread", &root_note); } } else { - let action = ui::Mention::new(note_context.ndb, note_context.img_cache, txn, reply_note.pubkey()) - .size(size) - .selectable(selectable) - .show(ui) - .inner; + let action = ui::Mention::new( + note_context.ndb, + note_context.img_cache, + txn, + reply_note.pubkey(), + ) + .size(size) + .selectable(selectable) + .show(ui) + .inner; if action.is_some() { note_action = action; diff --git a/crates/notedeck_columns/src/ui/profile/mod.rs b/crates/notedeck_columns/src/ui/profile/mod.rs index e27459f..0d30b75 100644 --- a/crates/notedeck_columns/src/ui/profile/mod.rs +++ b/crates/notedeck_columns/src/ui/profile/mod.rs @@ -140,9 +140,12 @@ impl<'a, 'd> ProfileView<'a, 'd> { ui.horizontal(|ui| { ui.put( pfp_rect, - ProfilePic::new(self.note_context.img_cache, get_profile_url(Some(&profile))) - .size(size) - .border(ProfilePic::border_stroke(ui)), + ProfilePic::new( + self.note_context.img_cache, + get_profile_url(Some(&profile)), + ) + .size(size) + .border(ProfilePic::border_stroke(ui)), ); if ui.add(copy_key_widget(&pfp_rect)).clicked() { diff --git a/crates/notedeck_columns/src/ui/timeline.rs b/crates/notedeck_columns/src/ui/timeline.rs index 9453f53..55187f8 100644 --- a/crates/notedeck_columns/src/ui/timeline.rs +++ b/crates/notedeck_columns/src/ui/timeline.rs @@ -138,7 +138,14 @@ fn timeline_ui( let txn = Transaction::new(note_context.ndb).expect("failed to create txn"); - TimelineTabView::new(timeline.current_view(), reversed, &txn, is_muted, note_context).show(ui) + TimelineTabView::new( + timeline.current_view(), + reversed, + &txn, + is_muted, + note_context, + ) + .show(ui) }); let at_top_after_scroll = scroll_output.state.offset.y == 0.0; @@ -338,12 +345,13 @@ impl<'a, 'd> TimelineTabView<'a, 'd> { let note_key = self.tab.notes[ind].key; - let note = if let Ok(note) = self.note_context.ndb.get_note_by_key(self.txn, note_key) { - note - } else { - warn!("failed to query note {:?}", note_key); - return 0; - }; + let note = + if let Ok(note) = self.note_context.ndb.get_note_by_key(self.txn, note_key) { + note + } else { + warn!("failed to query note {:?}", note_key); + return 0; + }; // should we mute the thread? we might not have it! let muted = if let Ok(root_id) = root_note_id_from_selected_id(