introduce NoteContext

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2025-03-07 17:02:02 -05:00
parent d85c6043b7
commit a9f473e3c9
12 changed files with 368 additions and 430 deletions

View File

@@ -1,16 +1,14 @@
use crate::draft::Draft;
use crate::ui;
use crate::ui::note::{NoteOptions, PostResponse, PostType};
use crate::ui::note::{PostResponse, PostType};
use enostr::{FilledKeypair, NoteId};
use nostrdb::Ndb;
use notedeck::{Images, NoteCache};
use super::contents::NoteContext;
use super::NoteOptions;
pub struct PostReplyView<'a> {
ndb: &'a Ndb,
pub struct PostReplyView<'a, 'd> {
note_context: &'a mut NoteContext<'d>,
poster: FilledKeypair<'a>,
note_cache: &'a mut NoteCache,
img_cache: &'a mut Images,
draft: &'a mut Draft,
note: &'a nostrdb::Note<'a>,
id_source: Option<egui::Id>,
@@ -18,26 +16,22 @@ pub struct PostReplyView<'a> {
note_options: NoteOptions,
}
impl<'a> PostReplyView<'a> {
impl<'a, 'd> PostReplyView<'a, 'd> {
#[allow(clippy::too_many_arguments)]
pub fn new(
ndb: &'a Ndb,
note_context: &'a mut NoteContext<'d>,
poster: FilledKeypair<'a>,
draft: &'a mut Draft,
note_cache: &'a mut NoteCache,
img_cache: &'a mut Images,
note: &'a nostrdb::Note<'a>,
inner_rect: egui::Rect,
note_options: NoteOptions,
) -> Self {
let id_source: Option<egui::Id> = None;
PostReplyView {
ndb,
note_context,
poster,
draft,
note,
note_cache,
img_cache,
id_source,
inner_rect,
note_options,
@@ -71,17 +65,11 @@ impl<'a> PostReplyView<'a> {
let selection = egui::Frame::none()
.outer_margin(egui::Margin::same(note_offset))
.show(ui, |ui| {
ui::NoteView::new(
self.ndb,
self.note_cache,
self.img_cache,
self.note,
self.note_options,
)
.actionbar(false)
.medium_pfp(true)
.options_button(true)
.show(ui)
ui::NoteView::new(self.note_context, self.note, self.note_options)
.actionbar(false)
.medium_pfp(true)
.options_button(true)
.show(ui)
})
.inner
.context_selection;
@@ -92,11 +80,9 @@ impl<'a> PostReplyView<'a> {
let mut post_response = {
ui::PostView::new(
self.ndb,
self.note_context,
self.draft,
PostType::Reply(NoteId::new(*replying_to)),
self.img_cache,
self.note_cache,
self.poster,
self.inner_rect,
self.note_options,