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:
@@ -304,22 +304,28 @@ fn render_nav_body(
|
|||||||
let action = {
|
let action = {
|
||||||
let draft = app.drafts.reply_mut(note.id());
|
let draft = app.drafts.reply_mut(note.id());
|
||||||
|
|
||||||
let response = egui::ScrollArea::vertical().show(ui, |ui| {
|
let response = egui::ScrollArea::vertical()
|
||||||
ui::PostReplyView::new(
|
.show(ui, |ui| {
|
||||||
ctx.ndb,
|
ui::PostReplyView::new(
|
||||||
poster,
|
ctx.ndb,
|
||||||
draft,
|
poster,
|
||||||
ctx.note_cache,
|
draft,
|
||||||
ctx.img_cache,
|
ctx.note_cache,
|
||||||
¬e,
|
ctx.img_cache,
|
||||||
inner_rect,
|
¬e,
|
||||||
app.note_options,
|
inner_rect,
|
||||||
)
|
app.note_options,
|
||||||
.id_source(id)
|
)
|
||||||
.show(ui)
|
.id_source(id)
|
||||||
});
|
.show(ui)
|
||||||
|
})
|
||||||
|
.inner;
|
||||||
|
|
||||||
response.inner.action
|
if let Some(selection) = response.context_selection {
|
||||||
|
selection.process(ui, ¬e);
|
||||||
|
}
|
||||||
|
|
||||||
|
response.action
|
||||||
};
|
};
|
||||||
|
|
||||||
action.map(Into::into)
|
action.map(Into::into)
|
||||||
@@ -340,22 +346,28 @@ fn render_nav_body(
|
|||||||
let poster = ctx.accounts.selected_or_first_nsec()?;
|
let poster = ctx.accounts.selected_or_first_nsec()?;
|
||||||
let draft = app.drafts.quote_mut(note.id());
|
let draft = app.drafts.quote_mut(note.id());
|
||||||
|
|
||||||
let response = egui::ScrollArea::vertical().show(ui, |ui| {
|
let response = egui::ScrollArea::vertical()
|
||||||
crate::ui::note::QuoteRepostView::new(
|
.show(ui, |ui| {
|
||||||
ctx.ndb,
|
crate::ui::note::QuoteRepostView::new(
|
||||||
poster,
|
ctx.ndb,
|
||||||
ctx.note_cache,
|
poster,
|
||||||
ctx.img_cache,
|
ctx.note_cache,
|
||||||
draft,
|
ctx.img_cache,
|
||||||
¬e,
|
draft,
|
||||||
inner_rect,
|
¬e,
|
||||||
app.note_options,
|
inner_rect,
|
||||||
)
|
app.note_options,
|
||||||
.id_source(id)
|
)
|
||||||
.show(ui)
|
.id_source(id)
|
||||||
});
|
.show(ui)
|
||||||
|
})
|
||||||
|
.inner;
|
||||||
|
|
||||||
response.inner.action.map(Into::into)
|
if let Some(selection) = response.context_selection {
|
||||||
|
selection.process(ui, ¬e);
|
||||||
|
}
|
||||||
|
|
||||||
|
response.action.map(Into::into)
|
||||||
}
|
}
|
||||||
|
|
||||||
Route::ComposeNote => {
|
Route::ComposeNote => {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ use notedeck::{supported_mime_hosted_at_url, Images, NoteCache};
|
|||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
use super::contents::render_note_preview;
|
use super::contents::render_note_preview;
|
||||||
|
use super::NoteContextSelection;
|
||||||
|
|
||||||
pub struct PostView<'a> {
|
pub struct PostView<'a> {
|
||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
@@ -81,6 +82,7 @@ impl PostAction {
|
|||||||
pub struct PostResponse {
|
pub struct PostResponse {
|
||||||
pub action: Option<PostAction>,
|
pub action: Option<PostAction>,
|
||||||
pub edit_response: egui::Response,
|
pub edit_response: egui::Response,
|
||||||
|
pub context_selection: Option<NoteContextSelection>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> PostView<'a> {
|
impl<'a> PostView<'a> {
|
||||||
@@ -313,25 +315,30 @@ impl<'a> PostView<'a> {
|
|||||||
.show(ui, |ui| {
|
.show(ui, |ui| {
|
||||||
ui.vertical(|ui| {
|
ui.vertical(|ui| {
|
||||||
let edit_response = ui.horizontal(|ui| self.editbox(txn, ui)).inner;
|
let edit_response = ui.horizontal(|ui| self.editbox(txn, ui)).inner;
|
||||||
|
let mut context_selection = None;
|
||||||
|
|
||||||
if let PostType::Quote(id) = self.post_type {
|
if let PostType::Quote(id) = self.post_type {
|
||||||
let avail_size = ui.available_size_before_wrap();
|
let avail_size = ui.available_size_before_wrap();
|
||||||
ui.with_layout(Layout::left_to_right(egui::Align::TOP), |ui| {
|
ui.with_layout(Layout::left_to_right(egui::Align::TOP), |ui| {
|
||||||
Frame::none().show(ui, |ui| {
|
context_selection = Frame::none()
|
||||||
ui.vertical(|ui| {
|
.show(ui, |ui| {
|
||||||
ui.set_max_width(avail_size.x * 0.8);
|
ui.vertical(|ui| {
|
||||||
render_note_preview(
|
ui.set_max_width(avail_size.x * 0.8);
|
||||||
ui,
|
render_note_preview(
|
||||||
self.ndb,
|
ui,
|
||||||
self.note_cache,
|
self.ndb,
|
||||||
self.img_cache,
|
self.note_cache,
|
||||||
txn,
|
self.img_cache,
|
||||||
id.bytes(),
|
txn,
|
||||||
nostrdb::NoteKey::new(0),
|
id.bytes(),
|
||||||
self.note_options,
|
nostrdb::NoteKey::new(0),
|
||||||
);
|
self.note_options,
|
||||||
});
|
)
|
||||||
});
|
})
|
||||||
|
.inner
|
||||||
|
.context_selection
|
||||||
|
})
|
||||||
|
.inner;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -393,6 +400,7 @@ impl<'a> PostView<'a> {
|
|||||||
PostResponse {
|
PostResponse {
|
||||||
action,
|
action,
|
||||||
edit_response,
|
edit_response,
|
||||||
|
context_selection,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.inner
|
.inner
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ impl<'a> PostReplyView<'a> {
|
|||||||
- ui::ProfilePic::medium_size() / 2.0
|
- ui::ProfilePic::medium_size() / 2.0
|
||||||
- ui::NoteView::expand_size() / 2.0;
|
- ui::NoteView::expand_size() / 2.0;
|
||||||
|
|
||||||
egui::Frame::none()
|
let selection = egui::Frame::none()
|
||||||
.outer_margin(egui::Margin::same(note_offset))
|
.outer_margin(egui::Margin::same(note_offset))
|
||||||
.show(ui, |ui| {
|
.show(ui, |ui| {
|
||||||
ui::NoteView::new(
|
ui::NoteView::new(
|
||||||
@@ -81,14 +81,16 @@ impl<'a> PostReplyView<'a> {
|
|||||||
.actionbar(false)
|
.actionbar(false)
|
||||||
.medium_pfp(true)
|
.medium_pfp(true)
|
||||||
.options_button(true)
|
.options_button(true)
|
||||||
.show(ui);
|
.show(ui)
|
||||||
});
|
})
|
||||||
|
.inner
|
||||||
|
.context_selection;
|
||||||
|
|
||||||
let id = self.id();
|
let id = self.id();
|
||||||
let replying_to = self.note.id();
|
let replying_to = self.note.id();
|
||||||
let rect_before_post = ui.min_rect();
|
let rect_before_post = ui.min_rect();
|
||||||
|
|
||||||
let post_response = {
|
let mut post_response = {
|
||||||
ui::PostView::new(
|
ui::PostView::new(
|
||||||
self.ndb,
|
self.ndb,
|
||||||
self.draft,
|
self.draft,
|
||||||
@@ -103,6 +105,8 @@ impl<'a> PostReplyView<'a> {
|
|||||||
.ui(self.note.txn().unwrap(), ui)
|
.ui(self.note.txn().unwrap(), ui)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
post_response.context_selection = selection;
|
||||||
|
|
||||||
//
|
//
|
||||||
// reply line
|
// reply line
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user