mirror of
https://github.com/aljazceru/notedeck.git
synced 2026-01-25 19:24:20 +01:00
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,
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user