refactor: remove processs_note_selection

Moved this to NoteOptionSelection::process

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2024-09-26 09:22:05 -07:00
parent 171889b3aa
commit 1a94c21d96
4 changed files with 13 additions and 14 deletions

View File

@@ -9,13 +9,9 @@ pub enum NoteOptionSelection {
CopyNoteId,
}
pub fn process_note_selection(
ui: &mut egui::Ui,
selection: Option<NoteOptionSelection>,
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();

View File

@@ -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, &note);
if let Some(selection) = resp.option_selection {
selection.process(ui, &note);
}
})
.response
}

View File

@@ -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, &note);
if let Some(selection) = note_response.option_selection {
selection.process(ui, &note);
}
});
ui::hline(ui);

View File

@@ -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, &note);
if let Some(selection) = resp.option_selection {
selection.process(ui, &note);
}
});
ui::hline(ui);