mirror of
https://github.com/aljazceru/notedeck.git
synced 2025-12-18 17:14:21 +01:00
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 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,
|
||||
¬e,
|
||||
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,
|
||||
¬e,
|
||||
inner_rect,
|
||||
app.note_options,
|
||||
)
|
||||
.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)
|
||||
@@ -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,
|
||||
¬e,
|
||||
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,
|
||||
¬e,
|
||||
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, ¬e);
|
||||
}
|
||||
|
||||
response.action.map(Into::into)
|
||||
}
|
||||
|
||||
Route::ComposeNote => {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user