diff --git a/src/note_options.rs b/src/note_options.rs index 580253c..adbf4e1 100644 --- a/src/note_options.rs +++ b/src/note_options.rs @@ -9,13 +9,9 @@ pub enum NoteOptionSelection { CopyNoteId, } -pub fn process_note_selection( - ui: &mut egui::Ui, - selection: Option, - note: &Note<'_>, -) { - if let Some(option) = selection { - match option { +impl NoteOptionSelection { + pub fn process(&self, ui: &mut egui::Ui, note: &Note<'_>) { + match self { NoteOptionSelection::CopyText => { ui.output_mut(|w| { w.copied_text = note.content().to_string(); diff --git a/src/ui/note/contents.rs b/src/ui/note/contents.rs index 327b9bd..d0bdc1f 100644 --- a/src/ui/note/contents.rs +++ b/src/ui/note/contents.rs @@ -1,6 +1,5 @@ use crate::images::ImageType; use crate::imgcache::ImageCache; -use crate::note_options::process_note_selection; use crate::notecache::NoteCache; use crate::ui::note::NoteOptions; use crate::ui::ProfilePic; @@ -112,7 +111,9 @@ pub fn render_note_preview( .use_more_options_button(true) .show(ui); - process_note_selection(ui, resp.option_selection, ¬e); + if let Some(selection) = resp.option_selection { + selection.process(ui, ¬e); + } }) .response } diff --git a/src/ui/thread.rs b/src/ui/thread.rs index 3f67f04..6376e8a 100644 --- a/src/ui/thread.rs +++ b/src/ui/thread.rs @@ -1,6 +1,5 @@ use crate::{ - actionbar::BarAction, imgcache::ImageCache, note_options::process_note_selection, - notecache::NoteCache, thread::Threads, ui, + actionbar::BarAction, imgcache::ImageCache, notecache::NoteCache, thread::Threads, ui, }; use nostrdb::{Ndb, NoteKey, Transaction}; use tracing::{error, warn}; @@ -126,7 +125,9 @@ impl<'a> ThreadView<'a> { action = Some(bar_action); } - process_note_selection(ui, note_response.option_selection, ¬e); + if let Some(selection) = note_response.option_selection { + selection.process(ui, ¬e); + } }); ui::hline(ui); diff --git a/src/ui/timeline.rs b/src/ui/timeline.rs index a9e112e..8aad4a4 100644 --- a/src/ui/timeline.rs +++ b/src/ui/timeline.rs @@ -1,5 +1,4 @@ use crate::draft::Draft; -use crate::note_options::process_note_selection; use crate::{ actionbar::BarAction, column::Columns, imgcache::ImageCache, notecache::NoteCache, timeline::TimelineId, ui, @@ -159,7 +158,9 @@ fn timeline_ui( debug!("clicked note"); } - process_note_selection(ui, resp.option_selection, ¬e); + if let Some(selection) = resp.option_selection { + selection.process(ui, ¬e); + } }); ui::hline(ui);