refactor: remove processs_note_selection
Moved this to NoteOptionSelection::process Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -9,13 +9,9 @@ pub enum NoteOptionSelection {
|
|||||||
CopyNoteId,
|
CopyNoteId,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn process_note_selection(
|
impl NoteOptionSelection {
|
||||||
ui: &mut egui::Ui,
|
pub fn process(&self, ui: &mut egui::Ui, note: &Note<'_>) {
|
||||||
selection: Option<NoteOptionSelection>,
|
match self {
|
||||||
note: &Note<'_>,
|
|
||||||
) {
|
|
||||||
if let Some(option) = selection {
|
|
||||||
match option {
|
|
||||||
NoteOptionSelection::CopyText => {
|
NoteOptionSelection::CopyText => {
|
||||||
ui.output_mut(|w| {
|
ui.output_mut(|w| {
|
||||||
w.copied_text = note.content().to_string();
|
w.copied_text = note.content().to_string();
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
use crate::images::ImageType;
|
use crate::images::ImageType;
|
||||||
use crate::imgcache::ImageCache;
|
use crate::imgcache::ImageCache;
|
||||||
use crate::note_options::process_note_selection;
|
|
||||||
use crate::notecache::NoteCache;
|
use crate::notecache::NoteCache;
|
||||||
use crate::ui::note::NoteOptions;
|
use crate::ui::note::NoteOptions;
|
||||||
use crate::ui::ProfilePic;
|
use crate::ui::ProfilePic;
|
||||||
@@ -112,7 +111,9 @@ pub fn render_note_preview(
|
|||||||
.use_more_options_button(true)
|
.use_more_options_button(true)
|
||||||
.show(ui);
|
.show(ui);
|
||||||
|
|
||||||
process_note_selection(ui, resp.option_selection, ¬e);
|
if let Some(selection) = resp.option_selection {
|
||||||
|
selection.process(ui, ¬e);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.response
|
.response
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
actionbar::BarAction, imgcache::ImageCache, note_options::process_note_selection,
|
actionbar::BarAction, imgcache::ImageCache, notecache::NoteCache, thread::Threads, ui,
|
||||||
notecache::NoteCache, thread::Threads, ui,
|
|
||||||
};
|
};
|
||||||
use nostrdb::{Ndb, NoteKey, Transaction};
|
use nostrdb::{Ndb, NoteKey, Transaction};
|
||||||
use tracing::{error, warn};
|
use tracing::{error, warn};
|
||||||
@@ -126,7 +125,9 @@ impl<'a> ThreadView<'a> {
|
|||||||
action = Some(bar_action);
|
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);
|
ui::hline(ui);
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
use crate::draft::Draft;
|
use crate::draft::Draft;
|
||||||
use crate::note_options::process_note_selection;
|
|
||||||
use crate::{
|
use crate::{
|
||||||
actionbar::BarAction, column::Columns, imgcache::ImageCache, notecache::NoteCache,
|
actionbar::BarAction, column::Columns, imgcache::ImageCache, notecache::NoteCache,
|
||||||
timeline::TimelineId, ui,
|
timeline::TimelineId, ui,
|
||||||
@@ -159,7 +158,9 @@ fn timeline_ui(
|
|||||||
debug!("clicked note");
|
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);
|
ui::hline(ui);
|
||||||
|
|||||||
Reference in New Issue
Block a user