fix context selection responses

closes: https://github.com/damus-io/notedeck/issues/574

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2025-03-05 15:59:38 -05:00
parent 63f8790380
commit e2be2ddd58
3 changed files with 73 additions and 49 deletions

View File

@@ -304,22 +304,28 @@ fn render_nav_body(
let action = {
let draft = app.drafts.reply_mut(note.id());
let response = egui::ScrollArea::vertical().show(ui, |ui| {
ui::PostReplyView::new(
ctx.ndb,
poster,
draft,
ctx.note_cache,
ctx.img_cache,
&note,
inner_rect,
app.note_options,
)
.id_source(id)
.show(ui)
});
let response = egui::ScrollArea::vertical()
.show(ui, |ui| {
ui::PostReplyView::new(
ctx.ndb,
poster,
draft,
ctx.note_cache,
ctx.img_cache,
&note,
inner_rect,
app.note_options,
)
.id_source(id)
.show(ui)
})
.inner;
response.inner.action
if let Some(selection) = response.context_selection {
selection.process(ui, &note);
}
response.action
};
action.map(Into::into)
@@ -340,22 +346,28 @@ fn render_nav_body(
let poster = ctx.accounts.selected_or_first_nsec()?;
let draft = app.drafts.quote_mut(note.id());
let response = egui::ScrollArea::vertical().show(ui, |ui| {
crate::ui::note::QuoteRepostView::new(
ctx.ndb,
poster,
ctx.note_cache,
ctx.img_cache,
draft,
&note,
inner_rect,
app.note_options,
)
.id_source(id)
.show(ui)
});
let response = egui::ScrollArea::vertical()
.show(ui, |ui| {
crate::ui::note::QuoteRepostView::new(
ctx.ndb,
poster,
ctx.note_cache,
ctx.img_cache,
draft,
&note,
inner_rect,
app.note_options,
)
.id_source(id)
.show(ui)
})
.inner;
response.inner.action.map(Into::into)
if let Some(selection) = response.context_selection {
selection.process(ui, &note);
}
response.action.map(Into::into)
}
Route::ComposeNote => {

View File

@@ -18,6 +18,7 @@ use notedeck::{supported_mime_hosted_at_url, Images, NoteCache};
use tracing::error;
use super::contents::render_note_preview;
use super::NoteContextSelection;
pub struct PostView<'a> {
ndb: &'a Ndb,
@@ -81,6 +82,7 @@ impl PostAction {
pub struct PostResponse {
pub action: Option<PostAction>,
pub edit_response: egui::Response,
pub context_selection: Option<NoteContextSelection>,
}
impl<'a> PostView<'a> {
@@ -313,25 +315,30 @@ impl<'a> PostView<'a> {
.show(ui, |ui| {
ui.vertical(|ui| {
let edit_response = ui.horizontal(|ui| self.editbox(txn, ui)).inner;
let mut context_selection = None;
if let PostType::Quote(id) = self.post_type {
let avail_size = ui.available_size_before_wrap();
ui.with_layout(Layout::left_to_right(egui::Align::TOP), |ui| {
Frame::none().show(ui, |ui| {
ui.vertical(|ui| {
ui.set_max_width(avail_size.x * 0.8);
render_note_preview(
ui,
self.ndb,
self.note_cache,
self.img_cache,
txn,
id.bytes(),
nostrdb::NoteKey::new(0),
self.note_options,
);
});
});
context_selection = Frame::none()
.show(ui, |ui| {
ui.vertical(|ui| {
ui.set_max_width(avail_size.x * 0.8);
render_note_preview(
ui,
self.ndb,
self.note_cache,
self.img_cache,
txn,
id.bytes(),
nostrdb::NoteKey::new(0),
self.note_options,
)
})
.inner
.context_selection
})
.inner;
});
}
@@ -393,6 +400,7 @@ impl<'a> PostView<'a> {
PostResponse {
action,
edit_response,
context_selection,
}
})
.inner

View File

@@ -68,7 +68,7 @@ impl<'a> PostReplyView<'a> {
- ui::ProfilePic::medium_size() / 2.0
- ui::NoteView::expand_size() / 2.0;
egui::Frame::none()
let selection = egui::Frame::none()
.outer_margin(egui::Margin::same(note_offset))
.show(ui, |ui| {
ui::NoteView::new(
@@ -81,14 +81,16 @@ impl<'a> PostReplyView<'a> {
.actionbar(false)
.medium_pfp(true)
.options_button(true)
.show(ui);
});
.show(ui)
})
.inner
.context_selection;
let id = self.id();
let replying_to = self.note.id();
let rect_before_post = ui.min_rect();
let post_response = {
let mut post_response = {
ui::PostView::new(
self.ndb,
self.draft,
@@ -103,6 +105,8 @@ impl<'a> PostReplyView<'a> {
.ui(self.note.txn().unwrap(), ui)
};
post_response.context_selection = selection;
//
// reply line
//