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