update NoteContentsDriller to NoteContext
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -7,7 +7,7 @@ pub mod reply;
|
||||
pub mod reply_description;
|
||||
|
||||
pub use contents::NoteContents;
|
||||
use contents::NoteContentsDriller;
|
||||
use contents::NoteContext;
|
||||
pub use context::{NoteContextButton, NoteContextSelection};
|
||||
pub use options::NoteOptions;
|
||||
pub use post::{PostAction, PostResponse, PostType, PostView};
|
||||
@@ -31,7 +31,7 @@ use notedeck::{CachedNote, NoteCache, NotedeckTextStyle};
|
||||
use super::profile::preview::one_line_display_name_widget;
|
||||
|
||||
pub struct NoteView<'a, 'd> {
|
||||
driller: &'a mut NoteContentsDriller<'d>,
|
||||
note_context: &'a mut NoteContext<'d>,
|
||||
parent: Option<NoteKey>,
|
||||
note: &'a nostrdb::Note<'a>,
|
||||
}
|
||||
@@ -69,13 +69,13 @@ impl View for NoteView<'_, '_> {
|
||||
}
|
||||
|
||||
impl<'a, 'd> NoteView<'a, 'd> {
|
||||
pub fn new(driller: &'a mut NoteContentsDriller<'d>, note: &'a nostrdb::Note<'a>) -> Self {
|
||||
driller.options.set_actionbar(true);
|
||||
driller.options.set_note_previews(true);
|
||||
pub fn new(note_context: &'a mut NoteContext<'d>, note: &'a nostrdb::Note<'a>) -> Self {
|
||||
note_context.options.set_actionbar(true);
|
||||
note_context.options.set_note_previews(true);
|
||||
|
||||
let parent: Option<NoteKey> = None;
|
||||
Self {
|
||||
driller,
|
||||
note_context,
|
||||
parent,
|
||||
note,
|
||||
}
|
||||
@@ -122,11 +122,11 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
||||
}
|
||||
|
||||
pub fn options(&self) -> NoteOptions {
|
||||
self.driller.options
|
||||
self.note_context.options
|
||||
}
|
||||
|
||||
pub fn options_mut(&mut self) -> &mut NoteOptions {
|
||||
&mut self.driller.options
|
||||
&mut self.note_context.options
|
||||
}
|
||||
|
||||
pub fn parent(mut self, parent: NoteKey) -> Self {
|
||||
@@ -140,7 +140,7 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
||||
|
||||
ui.with_layout(egui::Layout::left_to_right(egui::Align::TOP), |ui| {
|
||||
let profile = self
|
||||
.driller
|
||||
.note_context
|
||||
.ndb
|
||||
.get_profile_by_pubkey(txn, self.note.pubkey());
|
||||
|
||||
@@ -148,7 +148,7 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
||||
ui.spacing_mut().item_spacing.x = 2.0;
|
||||
|
||||
let cached_note = self
|
||||
.driller
|
||||
.note_context
|
||||
.note_cache
|
||||
.cached_note_or_insert_mut(note_key, self.note);
|
||||
|
||||
@@ -167,7 +167,7 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
||||
)
|
||||
});
|
||||
|
||||
ui.add(&mut NoteContents::new(self.driller, txn, self.note));
|
||||
ui.add(&mut NoteContents::new(self.note_context, txn, self.note));
|
||||
//});
|
||||
})
|
||||
.response
|
||||
@@ -214,13 +214,13 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
||||
|
||||
ui.put(
|
||||
rect,
|
||||
ui::ProfilePic::new(self.driller.img_cache, pic).size(size),
|
||||
ui::ProfilePic::new(self.note_context.img_cache, pic).size(size),
|
||||
)
|
||||
.on_hover_ui_at_pointer(|ui| {
|
||||
ui.set_max_width(300.0);
|
||||
ui.add(ui::ProfilePreview::new(
|
||||
profile.as_ref().unwrap(),
|
||||
self.driller.img_cache,
|
||||
self.note_context.img_cache,
|
||||
));
|
||||
});
|
||||
|
||||
@@ -238,7 +238,7 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
||||
|
||||
ui.put(
|
||||
rect,
|
||||
ui::ProfilePic::new(self.driller.img_cache, ui::ProfilePic::no_pfp_url())
|
||||
ui::ProfilePic::new(self.note_context.img_cache, ui::ProfilePic::no_pfp_url())
|
||||
.size(pfp_size),
|
||||
)
|
||||
.interact(sense)
|
||||
@@ -251,9 +251,9 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
||||
NoteResponse::new(self.textmode_ui(ui))
|
||||
} else {
|
||||
let txn = self.note.txn().expect("txn");
|
||||
if let Some(note_to_repost) = get_reposted_note(self.driller.ndb, txn, self.note) {
|
||||
if let Some(note_to_repost) = get_reposted_note(self.note_context.ndb, txn, self.note) {
|
||||
let profile = self
|
||||
.driller
|
||||
.note_context
|
||||
.ndb
|
||||
.get_profile_by_pubkey(txn, self.note.pubkey());
|
||||
|
||||
@@ -272,7 +272,7 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
||||
if let Ok(rec) = &profile {
|
||||
resp.on_hover_ui_at_pointer(|ui| {
|
||||
ui.set_max_width(300.0);
|
||||
ui.add(ui::ProfilePreview::new(rec, self.driller.img_cache));
|
||||
ui.add(ui::ProfilePreview::new(rec, self.note_context.img_cache));
|
||||
});
|
||||
}
|
||||
let color = ui.style().visuals.noninteractive().fg_stroke.color;
|
||||
@@ -283,7 +283,7 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
||||
.text_style(style.text_style()),
|
||||
);
|
||||
});
|
||||
NoteView::new(self.driller, ¬e_to_repost).show(ui)
|
||||
NoteView::new(self.note_context, ¬e_to_repost).show(ui)
|
||||
} else {
|
||||
self.show_standard(ui)
|
||||
}
|
||||
@@ -338,7 +338,7 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
||||
|
||||
let hitbox_id = note_hitbox_id(note_key, self.options(), self.parent);
|
||||
let profile = self
|
||||
.driller
|
||||
.note_context
|
||||
.ndb
|
||||
.get_profile_by_pubkey(txn, self.note.pubkey());
|
||||
let maybe_hitbox = maybe_note_hitbox(ui, hitbox_id);
|
||||
@@ -365,7 +365,7 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
||||
ui.horizontal_centered(|ui| {
|
||||
selected_option = NoteView::note_header(
|
||||
ui,
|
||||
self.driller.note_cache,
|
||||
self.note_context.note_cache,
|
||||
self.note,
|
||||
&profile,
|
||||
self.options(),
|
||||
@@ -377,7 +377,7 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
||||
});
|
||||
|
||||
let note_reply = self
|
||||
.driller
|
||||
.note_context
|
||||
.note_cache
|
||||
.cached_note_or_insert_mut(note_key, self.note)
|
||||
.reply
|
||||
@@ -385,7 +385,7 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
||||
|
||||
if note_reply.reply().is_some() {
|
||||
let action = ui
|
||||
.horizontal(|ui| reply_desc(ui, txn, ¬e_reply, self.driller))
|
||||
.horizontal(|ui| reply_desc(ui, txn, ¬e_reply, self.note_context))
|
||||
.inner;
|
||||
|
||||
if action.is_some() {
|
||||
@@ -395,7 +395,7 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
||||
});
|
||||
});
|
||||
|
||||
let mut contents = NoteContents::new(self.driller, txn, self.note);
|
||||
let mut contents = NoteContents::new(self.note_context, txn, self.note);
|
||||
|
||||
ui.add(&mut contents);
|
||||
|
||||
@@ -423,7 +423,7 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
||||
ui.with_layout(egui::Layout::top_down(egui::Align::LEFT), |ui| {
|
||||
selected_option = NoteView::note_header(
|
||||
ui,
|
||||
self.driller.note_cache,
|
||||
self.note_context.note_cache,
|
||||
self.note,
|
||||
&profile,
|
||||
self.options(),
|
||||
@@ -434,14 +434,14 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
||||
ui.spacing_mut().item_spacing.x = 2.0;
|
||||
|
||||
let note_reply = self
|
||||
.driller
|
||||
.note_context
|
||||
.note_cache
|
||||
.cached_note_or_insert_mut(note_key, self.note)
|
||||
.reply
|
||||
.borrow(self.note.tags());
|
||||
|
||||
if note_reply.reply().is_some() {
|
||||
let action = reply_desc(ui, txn, ¬e_reply, self.driller);
|
||||
let action = reply_desc(ui, txn, ¬e_reply, self.note_context);
|
||||
|
||||
if action.is_some() {
|
||||
note_action = action;
|
||||
@@ -449,7 +449,7 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
||||
}
|
||||
});
|
||||
|
||||
let mut contents = NoteContents::new(self.driller, txn, self.note);
|
||||
let mut contents = NoteContents::new(self.note_context, txn, self.note);
|
||||
ui.add(&mut contents);
|
||||
|
||||
if let Some(action) = contents.action() {
|
||||
@@ -470,8 +470,8 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
||||
|
||||
let note_action = if note_hitbox_clicked(ui, hitbox_id, &response.rect, maybe_hitbox) {
|
||||
if let Ok(selection) = ThreadSelection::from_note_id(
|
||||
self.driller.ndb,
|
||||
self.driller.note_cache,
|
||||
self.note_context.ndb,
|
||||
self.note_context.note_cache,
|
||||
self.note.txn().unwrap(),
|
||||
NoteId::new(*self.note.id()),
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user