address PR comments

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2024-09-18 11:07:11 -04:00
parent 06336a14ef
commit 6e77d20197
7 changed files with 36 additions and 72 deletions

View File

@@ -206,9 +206,7 @@ mod preview {
PostPreview {
ndb,
img_cache: ImageCache::new(".".into()),
note_cache: NoteCache {
cache: Default::default(),
},
note_cache: NoteCache::default(),
draft: Draft::new(),
poster: FullKeypair::generate(),
}

View File

@@ -1,20 +1,16 @@
use enostr::{FilledKeypair, RelayPool};
use enostr::FilledKeypair;
use nostrdb::Ndb;
use crate::{
draft::Drafts, imgcache::ImageCache, notecache::NoteCache,
post_action_executor::PostActionExecutor, ui,
};
use crate::{draft::Draft, imgcache::ImageCache, notecache::NoteCache, ui};
use super::PostResponse;
pub struct QuoteRepostView<'a> {
ndb: &'a Ndb,
poster: FilledKeypair<'a>,
pool: &'a mut RelayPool,
note_cache: &'a mut NoteCache,
img_cache: &'a mut ImageCache,
drafts: &'a mut Drafts,
draft: &'a mut Draft,
quoting_note: &'a nostrdb::Note<'a>,
id_source: Option<egui::Id>,
}
@@ -23,20 +19,18 @@ impl<'a> QuoteRepostView<'a> {
pub fn new(
ndb: &'a Ndb,
poster: FilledKeypair<'a>,
pool: &'a mut RelayPool,
note_cache: &'a mut NoteCache,
img_cache: &'a mut ImageCache,
drafts: &'a mut Drafts,
draft: &'a mut Draft,
quoting_note: &'a nostrdb::Note<'a>,
) -> Self {
let id_source: Option<egui::Id> = None;
QuoteRepostView {
ndb,
poster,
pool,
note_cache,
img_cache,
drafts,
draft,
quoting_note,
id_source,
}
@@ -47,10 +41,9 @@ impl<'a> QuoteRepostView<'a> {
let quoting_note_id = self.quoting_note.id();
let post_response = {
let draft = self.drafts.quote_mut(quoting_note_id);
ui::PostView::new(
self.ndb,
draft,
self.draft,
crate::draft::DraftSource::Quote(quoting_note_id),
self.img_cache,
self.note_cache,
@@ -60,19 +53,6 @@ impl<'a> QuoteRepostView<'a> {
.ui(self.quoting_note.txn().unwrap(), ui)
};
if let Some(action) = &post_response.action {
PostActionExecutor::execute(
&self.poster,
action,
self.pool,
self.drafts,
|np, seckey| np.to_quote(seckey, self.quoting_note),
|drafts| {
drafts.quote_mut(quoting_note_id).clear();
},
);
}
post_response
}

View File

@@ -94,14 +94,11 @@ impl<'a> PostReplyView<'a> {
if let Some(action) = &post_response.action {
PostActionExecutor::execute(
&self.poster,
self.poster,
action,
self.pool,
self.drafts,
self.drafts.reply_mut(replying_to),
|np, seckey| np.to_reply(seckey, self.note),
|drafts| {
drafts.reply_mut(replying_to).clear();
},
);
}