@@ -53,8 +53,15 @@ pub fn render_timeline_route(
|
|||||||
match route {
|
match route {
|
||||||
TimelineRoute::Timeline(timeline_id) => {
|
TimelineRoute::Timeline(timeline_id) => {
|
||||||
if show_postbox {
|
if show_postbox {
|
||||||
if let Some(kp) = accounts.selected_or_first_nsec() {
|
let kp = accounts.selected_or_first_nsec()?;
|
||||||
ui::timeline::postbox_view(ndb, kp, pool, drafts, img_cache, note_cache, ui);
|
let draft = drafts.compose_mut();
|
||||||
|
let response =
|
||||||
|
ui::timeline::postbox_view(ndb, kp, draft, img_cache, note_cache, ui);
|
||||||
|
|
||||||
|
if let Some(action) = response.action {
|
||||||
|
PostActionExecutor::execute(kp, &action, pool, draft, |np, seckey| {
|
||||||
|
np.to_note(seckey)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,18 +108,22 @@ pub fn render_timeline_route(
|
|||||||
};
|
};
|
||||||
|
|
||||||
let id = egui::Id::new(("post", col, note.key().unwrap()));
|
let id = egui::Id::new(("post", col, note.key().unwrap()));
|
||||||
|
let poster = accounts.selected_or_first_nsec()?;
|
||||||
|
let draft = drafts.reply_mut(note.id());
|
||||||
|
|
||||||
if let Some(poster) = accounts.selected_or_first_nsec() {
|
let response = egui::ScrollArea::vertical().show(ui, |ui| {
|
||||||
let response = egui::ScrollArea::vertical().show(ui, |ui| {
|
ui::PostReplyView::new(ndb, poster, draft, note_cache, img_cache, ¬e)
|
||||||
ui::PostReplyView::new(ndb, poster, pool, drafts, note_cache, img_cache, ¬e)
|
.id_source(id)
|
||||||
.id_source(id)
|
.show(ui)
|
||||||
.show(ui)
|
});
|
||||||
|
|
||||||
|
if let Some(action) = &response.inner.action {
|
||||||
|
PostActionExecutor::execute(poster, action, pool, draft, |np, seckey| {
|
||||||
|
np.to_reply(seckey, ¬e)
|
||||||
});
|
});
|
||||||
|
|
||||||
Some(TimelineRouteResponse::post(response.inner))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Some(TimelineRouteResponse::post(response.inner))
|
||||||
}
|
}
|
||||||
|
|
||||||
TimelineRoute::Quote(id) => {
|
TimelineRoute::Quote(id) => {
|
||||||
|
|||||||
@@ -1,19 +1,17 @@
|
|||||||
use crate::draft::Drafts;
|
use crate::draft::Draft;
|
||||||
use crate::imgcache::ImageCache;
|
use crate::imgcache::ImageCache;
|
||||||
use crate::notecache::NoteCache;
|
use crate::notecache::NoteCache;
|
||||||
use crate::post_action_executor::PostActionExecutor;
|
|
||||||
use crate::ui;
|
use crate::ui;
|
||||||
use crate::ui::note::PostResponse;
|
use crate::ui::note::PostResponse;
|
||||||
use enostr::{FilledKeypair, RelayPool};
|
use enostr::FilledKeypair;
|
||||||
use nostrdb::Ndb;
|
use nostrdb::Ndb;
|
||||||
|
|
||||||
pub struct PostReplyView<'a> {
|
pub struct PostReplyView<'a> {
|
||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
poster: FilledKeypair<'a>,
|
poster: FilledKeypair<'a>,
|
||||||
pool: &'a mut RelayPool,
|
|
||||||
note_cache: &'a mut NoteCache,
|
note_cache: &'a mut NoteCache,
|
||||||
img_cache: &'a mut ImageCache,
|
img_cache: &'a mut ImageCache,
|
||||||
drafts: &'a mut Drafts,
|
draft: &'a mut Draft,
|
||||||
note: &'a nostrdb::Note<'a>,
|
note: &'a nostrdb::Note<'a>,
|
||||||
id_source: Option<egui::Id>,
|
id_source: Option<egui::Id>,
|
||||||
}
|
}
|
||||||
@@ -22,8 +20,7 @@ impl<'a> PostReplyView<'a> {
|
|||||||
pub fn new(
|
pub fn new(
|
||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
poster: FilledKeypair<'a>,
|
poster: FilledKeypair<'a>,
|
||||||
pool: &'a mut RelayPool,
|
draft: &'a mut Draft,
|
||||||
drafts: &'a mut Drafts,
|
|
||||||
note_cache: &'a mut NoteCache,
|
note_cache: &'a mut NoteCache,
|
||||||
img_cache: &'a mut ImageCache,
|
img_cache: &'a mut ImageCache,
|
||||||
note: &'a nostrdb::Note<'a>,
|
note: &'a nostrdb::Note<'a>,
|
||||||
@@ -32,8 +29,7 @@ impl<'a> PostReplyView<'a> {
|
|||||||
PostReplyView {
|
PostReplyView {
|
||||||
ndb,
|
ndb,
|
||||||
poster,
|
poster,
|
||||||
pool,
|
draft,
|
||||||
drafts,
|
|
||||||
note,
|
note,
|
||||||
note_cache,
|
note_cache,
|
||||||
img_cache,
|
img_cache,
|
||||||
@@ -79,10 +75,9 @@ impl<'a> PostReplyView<'a> {
|
|||||||
let rect_before_post = ui.min_rect();
|
let rect_before_post = ui.min_rect();
|
||||||
|
|
||||||
let post_response = {
|
let post_response = {
|
||||||
let draft = self.drafts.reply_mut(replying_to);
|
|
||||||
ui::PostView::new(
|
ui::PostView::new(
|
||||||
self.ndb,
|
self.ndb,
|
||||||
draft,
|
self.draft,
|
||||||
crate::draft::DraftSource::Reply(replying_to),
|
crate::draft::DraftSource::Reply(replying_to),
|
||||||
self.img_cache,
|
self.img_cache,
|
||||||
self.note_cache,
|
self.note_cache,
|
||||||
@@ -92,16 +87,6 @@ impl<'a> PostReplyView<'a> {
|
|||||||
.ui(self.note.txn().unwrap(), ui)
|
.ui(self.note.txn().unwrap(), ui)
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(action) = &post_response.action {
|
|
||||||
PostActionExecutor::execute(
|
|
||||||
self.poster,
|
|
||||||
action,
|
|
||||||
self.pool,
|
|
||||||
self.drafts.reply_mut(replying_to),
|
|
||||||
|np, seckey| np.to_reply(seckey, self.note),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// reply line
|
// reply line
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
use crate::post_action_executor::PostActionExecutor;
|
use crate::draft::Draft;
|
||||||
use crate::{
|
use crate::{
|
||||||
actionbar::BarAction, column::Columns, draft::Drafts, imgcache::ImageCache,
|
actionbar::BarAction, column::Columns, imgcache::ImageCache, notecache::NoteCache,
|
||||||
notecache::NoteCache, timeline::TimelineId, ui,
|
timeline::TimelineId, ui,
|
||||||
};
|
};
|
||||||
use egui::containers::scroll_area::ScrollBarVisibility;
|
use egui::containers::scroll_area::ScrollBarVisibility;
|
||||||
use egui::{Direction, Layout};
|
use egui::{Direction, Layout};
|
||||||
use egui_tabs::TabColor;
|
use egui_tabs::TabColor;
|
||||||
use enostr::{FilledKeypair, RelayPool};
|
use enostr::FilledKeypair;
|
||||||
use nostrdb::{Ndb, Transaction};
|
use nostrdb::{Ndb, Transaction};
|
||||||
use tracing::{debug, error, warn};
|
use tracing::{debug, error, warn};
|
||||||
|
|
||||||
|
use super::note::PostResponse;
|
||||||
|
|
||||||
pub struct TimelineView<'a> {
|
pub struct TimelineView<'a> {
|
||||||
timeline_id: TimelineId,
|
timeline_id: TimelineId,
|
||||||
columns: &'a mut Columns,
|
columns: &'a mut Columns,
|
||||||
@@ -171,29 +173,22 @@ fn timeline_ui(
|
|||||||
pub fn postbox_view<'a>(
|
pub fn postbox_view<'a>(
|
||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
key: FilledKeypair<'a>,
|
key: FilledKeypair<'a>,
|
||||||
pool: &'a mut RelayPool,
|
draft: &'a mut Draft,
|
||||||
drafts: &'a mut Drafts,
|
|
||||||
img_cache: &'a mut ImageCache,
|
img_cache: &'a mut ImageCache,
|
||||||
note_cache: &'a mut NoteCache,
|
note_cache: &'a mut NoteCache,
|
||||||
ui: &'a mut egui::Ui,
|
ui: &'a mut egui::Ui,
|
||||||
) {
|
) -> PostResponse {
|
||||||
// show a postbox in the first timeline
|
// show a postbox in the first timeline
|
||||||
let txn = Transaction::new(ndb).expect("txn");
|
let txn = Transaction::new(ndb).expect("txn");
|
||||||
let response = ui::PostView::new(
|
ui::PostView::new(
|
||||||
ndb,
|
ndb,
|
||||||
drafts.compose_mut(),
|
draft,
|
||||||
crate::draft::DraftSource::Compose,
|
crate::draft::DraftSource::Compose,
|
||||||
img_cache,
|
img_cache,
|
||||||
note_cache,
|
note_cache,
|
||||||
key,
|
key,
|
||||||
)
|
)
|
||||||
.ui(&txn, ui);
|
.ui(&txn, ui)
|
||||||
|
|
||||||
if let Some(action) = response.action {
|
|
||||||
PostActionExecutor::execute(key, &action, pool, drafts.compose_mut(), |np, seckey| {
|
|
||||||
np.to_note(seckey)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tabs_ui(ui: &mut egui::Ui) -> i32 {
|
fn tabs_ui(ui: &mut egui::Ui) -> i32 {
|
||||||
|
|||||||
Reference in New Issue
Block a user