commit 87b4b5fc70e37f9829259879c3c6b38dbf3ec70f
parent b3569e90d622400e46b94b102c83381d78599875
Author: kernelkind <kernelkind@gmail.com>
Date: Tue, 17 Jun 2025 12:36:18 -0400
add preview flag to `NoteAction`
Signed-off-by: kernelkind <kernelkind@gmail.com>
Diffstat:
5 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/crates/notedeck/src/note/action.rs b/crates/notedeck/src/note/action.rs
@@ -18,7 +18,7 @@ pub enum NoteAction {
Profile(Pubkey),
/// User has clicked a note link
- Note(NoteId),
+ Note { note_id: NoteId, preview: bool },
/// User has selected some context option
Context(ContextSelection),
@@ -30,6 +30,15 @@ pub enum NoteAction {
Media(MediaAction),
}
+impl NoteAction {
+ pub fn note(id: NoteId) -> NoteAction {
+ NoteAction::Note {
+ note_id: id,
+ preview: false,
+ }
+ }
+}
+
#[derive(Debug, Eq, PartialEq, Clone)]
pub enum ZapAction {
Send(ZapTargetAmount),
diff --git a/crates/notedeck_columns/src/actionbar.rs b/crates/notedeck_columns/src/actionbar.rs
@@ -60,7 +60,7 @@ fn execute_note_action(
router_action = Some(RouterAction::route_to(Route::Timeline(kind.clone())));
timeline_res = timeline_cache.open(ndb, note_cache, txn, pool, &kind);
}
- NoteAction::Note(note_id) => 'ex: {
+ NoteAction::Note { note_id, preview } => 'ex: {
let Ok(thread_selection) = ThreadSelection::from_note_id(ndb, note_cache, txn, note_id)
else {
tracing::error!("No thread selection for {}?", hex::encode(note_id.bytes()));
diff --git a/crates/notedeck_columns/src/ui/thread.rs b/crates/notedeck_columns/src/ui/thread.rs
@@ -184,7 +184,13 @@ fn show_notes(
}
fn strip_note_action(action: NoteAction) -> Option<NoteAction> {
- if matches!(action, NoteAction::Note(_)) {
+ if matches!(
+ action,
+ NoteAction::Note {
+ note_id: _,
+ preview: false,
+ }
+ ) {
return None;
}
diff --git a/crates/notedeck_ui/src/note/contents.rs b/crates/notedeck_ui/src/note/contents.rs
@@ -270,11 +270,17 @@ pub fn render_note_contents(
}
});
- let preview_note_action = if let Some((id, _block_str)) = inline_note {
- render_note_preview(ui, note_context, cur_acc, txn, id, note_key, options, jobs).action
- } else {
- None
- };
+ let preview_note_action = inline_note.and_then(|(id, _)| {
+ render_note_preview(ui, note_context, cur_acc, txn, id, note_key, options, jobs)
+ .action
+ .map(|a| match a {
+ NoteAction::Note { note_id, .. } => NoteAction::Note {
+ note_id,
+ preview: true,
+ },
+ other => other,
+ })
+ });
let mut media_action = None;
if !supported_medias.is_empty() && !options.has_textmode() {
diff --git a/crates/notedeck_ui/src/note/mod.rs b/crates/notedeck_ui/src/note/mod.rs
@@ -609,7 +609,7 @@ impl<'a, 'd> NoteView<'a, 'd> {
}
note_action = note_hitbox_clicked(ui, hitbox_id, &response.response.rect, maybe_hitbox)
- .then_some(NoteAction::Note(NoteId::new(*self.note.id())))
+ .then_some(NoteAction::note(NoteId::new(*self.note.id())))
.or(note_action);
NoteResponse::new(response.response)