Revert driller
This reverts commitcec49c83bd. Revert "update NoteContentsDriller to NoteContext" This reverts commit65bd6a65f9. Revert "introduce the driller" This reverts commit95d618e7fe.
This commit is contained in:
@@ -16,7 +16,7 @@ use crate::{
|
|||||||
column::NavTitle,
|
column::NavTitle,
|
||||||
configure_deck::ConfigureDeckView,
|
configure_deck::ConfigureDeckView,
|
||||||
edit_deck::{EditDeckResponse, EditDeckView},
|
edit_deck::{EditDeckResponse, EditDeckView},
|
||||||
note::{contents::NoteContext, PostAction, PostType},
|
note::{PostAction, PostType},
|
||||||
profile::EditProfileView,
|
profile::EditProfileView,
|
||||||
support::SupportView,
|
support::SupportView,
|
||||||
RelayView, View,
|
RelayView, View,
|
||||||
@@ -243,22 +243,19 @@ fn render_nav_body(
|
|||||||
col: usize,
|
col: usize,
|
||||||
inner_rect: egui::Rect,
|
inner_rect: egui::Rect,
|
||||||
) -> Option<RenderNavAction> {
|
) -> Option<RenderNavAction> {
|
||||||
let mut note_context = NoteContext {
|
|
||||||
ndb: ctx.ndb,
|
|
||||||
img_cache: ctx.img_cache,
|
|
||||||
note_cache: ctx.note_cache,
|
|
||||||
options: app.note_options,
|
|
||||||
};
|
|
||||||
match top {
|
match top {
|
||||||
Route::Timeline(kind) => render_timeline_route(
|
Route::Timeline(kind) => render_timeline_route(
|
||||||
|
ctx.ndb,
|
||||||
|
ctx.img_cache,
|
||||||
ctx.unknown_ids,
|
ctx.unknown_ids,
|
||||||
|
ctx.note_cache,
|
||||||
&mut app.timeline_cache,
|
&mut app.timeline_cache,
|
||||||
ctx.accounts,
|
ctx.accounts,
|
||||||
kind,
|
kind,
|
||||||
col,
|
col,
|
||||||
|
app.note_options,
|
||||||
depth,
|
depth,
|
||||||
ui,
|
ui,
|
||||||
&mut note_context,
|
|
||||||
),
|
),
|
||||||
Route::Accounts(amr) => {
|
Route::Accounts(amr) => {
|
||||||
let mut action = render_accounts_route(
|
let mut action = render_accounts_route(
|
||||||
@@ -305,9 +302,18 @@ fn render_nav_body(
|
|||||||
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().show(ui, |ui| {
|
||||||
ui::PostReplyView::new(&mut note_context, poster, draft, ¬e, inner_rect)
|
ui::PostReplyView::new(
|
||||||
.id_source(id)
|
ctx.ndb,
|
||||||
.show(ui)
|
poster,
|
||||||
|
draft,
|
||||||
|
ctx.note_cache,
|
||||||
|
ctx.img_cache,
|
||||||
|
¬e,
|
||||||
|
inner_rect,
|
||||||
|
app.note_options,
|
||||||
|
)
|
||||||
|
.id_source(id)
|
||||||
|
.show(ui)
|
||||||
});
|
});
|
||||||
|
|
||||||
response.inner.action
|
response.inner.action
|
||||||
@@ -333,11 +339,14 @@ fn render_nav_body(
|
|||||||
|
|
||||||
let response = egui::ScrollArea::vertical().show(ui, |ui| {
|
let response = egui::ScrollArea::vertical().show(ui, |ui| {
|
||||||
crate::ui::note::QuoteRepostView::new(
|
crate::ui::note::QuoteRepostView::new(
|
||||||
&mut note_context,
|
ctx.ndb,
|
||||||
poster,
|
poster,
|
||||||
|
ctx.note_cache,
|
||||||
|
ctx.img_cache,
|
||||||
draft,
|
draft,
|
||||||
¬e,
|
¬e,
|
||||||
inner_rect,
|
inner_rect,
|
||||||
|
app.note_options,
|
||||||
)
|
)
|
||||||
.id_source(id)
|
.id_source(id)
|
||||||
.show(ui)
|
.show(ui)
|
||||||
@@ -351,9 +360,17 @@ fn render_nav_body(
|
|||||||
let draft = app.drafts.compose_mut();
|
let draft = app.drafts.compose_mut();
|
||||||
|
|
||||||
let txn = Transaction::new(ctx.ndb).expect("txn");
|
let txn = Transaction::new(ctx.ndb).expect("txn");
|
||||||
let post_response =
|
let post_response = ui::PostView::new(
|
||||||
ui::PostView::new(&mut note_context, draft, PostType::New, kp, inner_rect)
|
ctx.ndb,
|
||||||
.ui(&txn, ui);
|
draft,
|
||||||
|
PostType::New,
|
||||||
|
ctx.img_cache,
|
||||||
|
ctx.note_cache,
|
||||||
|
kp,
|
||||||
|
inner_rect,
|
||||||
|
app.note_options,
|
||||||
|
)
|
||||||
|
.ui(&txn, ui);
|
||||||
|
|
||||||
post_response.action.map(Into::into)
|
post_response.action.map(Into::into)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,25 +2,29 @@ use crate::{
|
|||||||
nav::RenderNavAction,
|
nav::RenderNavAction,
|
||||||
profile::ProfileAction,
|
profile::ProfileAction,
|
||||||
timeline::{TimelineCache, TimelineKind},
|
timeline::{TimelineCache, TimelineKind},
|
||||||
ui::{self, note::contents::NoteContext, profile::ProfileView},
|
ui::{self, note::NoteOptions, profile::ProfileView},
|
||||||
};
|
};
|
||||||
|
|
||||||
use enostr::Pubkey;
|
use enostr::Pubkey;
|
||||||
use notedeck::{Accounts, MuteFun, UnknownIds};
|
use nostrdb::Ndb;
|
||||||
|
use notedeck::{Accounts, Images, MuteFun, NoteCache, UnknownIds};
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn render_timeline_route(
|
pub fn render_timeline_route(
|
||||||
|
ndb: &Ndb,
|
||||||
|
img_cache: &mut Images,
|
||||||
unknown_ids: &mut UnknownIds,
|
unknown_ids: &mut UnknownIds,
|
||||||
|
note_cache: &mut NoteCache,
|
||||||
timeline_cache: &mut TimelineCache,
|
timeline_cache: &mut TimelineCache,
|
||||||
accounts: &mut Accounts,
|
accounts: &mut Accounts,
|
||||||
kind: &TimelineKind,
|
kind: &TimelineKind,
|
||||||
col: usize,
|
col: usize,
|
||||||
|
mut note_options: NoteOptions,
|
||||||
depth: usize,
|
depth: usize,
|
||||||
ui: &mut egui::Ui,
|
ui: &mut egui::Ui,
|
||||||
note_context: &mut NoteContext,
|
|
||||||
) -> Option<RenderNavAction> {
|
) -> Option<RenderNavAction> {
|
||||||
if kind == &TimelineKind::Universe {
|
if kind == &TimelineKind::Universe {
|
||||||
note_context.options.set_hide_media(true);
|
note_options.set_hide_media(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
match kind {
|
match kind {
|
||||||
@@ -30,9 +34,16 @@ pub fn render_timeline_route(
|
|||||||
| TimelineKind::Universe
|
| TimelineKind::Universe
|
||||||
| TimelineKind::Hashtag(_)
|
| TimelineKind::Hashtag(_)
|
||||||
| TimelineKind::Generic(_) => {
|
| TimelineKind::Generic(_) => {
|
||||||
let note_action =
|
let note_action = ui::TimelineView::new(
|
||||||
ui::TimelineView::new(kind, timeline_cache, &accounts.mutefun(), note_context)
|
kind,
|
||||||
.ui(ui);
|
timeline_cache,
|
||||||
|
ndb,
|
||||||
|
note_cache,
|
||||||
|
img_cache,
|
||||||
|
note_options,
|
||||||
|
&accounts.mutefun(),
|
||||||
|
)
|
||||||
|
.ui(ui);
|
||||||
|
|
||||||
note_action.map(RenderNavAction::NoteAction)
|
note_action.map(RenderNavAction::NoteAction)
|
||||||
}
|
}
|
||||||
@@ -42,18 +53,28 @@ pub fn render_timeline_route(
|
|||||||
render_profile_route(
|
render_profile_route(
|
||||||
pubkey,
|
pubkey,
|
||||||
accounts,
|
accounts,
|
||||||
|
ndb,
|
||||||
timeline_cache,
|
timeline_cache,
|
||||||
|
img_cache,
|
||||||
|
note_cache,
|
||||||
unknown_ids,
|
unknown_ids,
|
||||||
col,
|
col,
|
||||||
ui,
|
ui,
|
||||||
&accounts.mutefun(),
|
&accounts.mutefun(),
|
||||||
note_context,
|
note_options,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
// we render profiles like timelines if they are at the root
|
// we render profiles like timelines if they are at the root
|
||||||
let note_action =
|
let note_action = ui::TimelineView::new(
|
||||||
ui::TimelineView::new(kind, timeline_cache, &accounts.mutefun(), note_context)
|
kind,
|
||||||
.ui(ui);
|
timeline_cache,
|
||||||
|
ndb,
|
||||||
|
note_cache,
|
||||||
|
img_cache,
|
||||||
|
note_options,
|
||||||
|
&accounts.mutefun(),
|
||||||
|
)
|
||||||
|
.ui(ui);
|
||||||
|
|
||||||
note_action.map(RenderNavAction::NoteAction)
|
note_action.map(RenderNavAction::NoteAction)
|
||||||
}
|
}
|
||||||
@@ -61,10 +82,13 @@ pub fn render_timeline_route(
|
|||||||
|
|
||||||
TimelineKind::Thread(id) => ui::ThreadView::new(
|
TimelineKind::Thread(id) => ui::ThreadView::new(
|
||||||
timeline_cache,
|
timeline_cache,
|
||||||
|
ndb,
|
||||||
|
note_cache,
|
||||||
unknown_ids,
|
unknown_ids,
|
||||||
|
img_cache,
|
||||||
id.selected_or_root(),
|
id.selected_or_root(),
|
||||||
|
note_options,
|
||||||
&accounts.mutefun(),
|
&accounts.mutefun(),
|
||||||
note_context,
|
|
||||||
)
|
)
|
||||||
.id_source(egui::Id::new(("threadscroll", col)))
|
.id_source(egui::Id::new(("threadscroll", col)))
|
||||||
.ui(ui)
|
.ui(ui)
|
||||||
@@ -76,21 +100,27 @@ pub fn render_timeline_route(
|
|||||||
pub fn render_profile_route(
|
pub fn render_profile_route(
|
||||||
pubkey: &Pubkey,
|
pubkey: &Pubkey,
|
||||||
accounts: &Accounts,
|
accounts: &Accounts,
|
||||||
|
ndb: &Ndb,
|
||||||
timeline_cache: &mut TimelineCache,
|
timeline_cache: &mut TimelineCache,
|
||||||
|
img_cache: &mut Images,
|
||||||
|
note_cache: &mut NoteCache,
|
||||||
unknown_ids: &mut UnknownIds,
|
unknown_ids: &mut UnknownIds,
|
||||||
col: usize,
|
col: usize,
|
||||||
ui: &mut egui::Ui,
|
ui: &mut egui::Ui,
|
||||||
is_muted: &MuteFun,
|
is_muted: &MuteFun,
|
||||||
note_context: &mut NoteContext,
|
note_options: NoteOptions,
|
||||||
) -> Option<RenderNavAction> {
|
) -> Option<RenderNavAction> {
|
||||||
let action = ProfileView::new(
|
let action = ProfileView::new(
|
||||||
pubkey,
|
pubkey,
|
||||||
accounts,
|
accounts,
|
||||||
col,
|
col,
|
||||||
timeline_cache,
|
timeline_cache,
|
||||||
|
ndb,
|
||||||
|
note_cache,
|
||||||
|
img_cache,
|
||||||
unknown_ids,
|
unknown_ids,
|
||||||
is_muted,
|
is_muted,
|
||||||
note_context,
|
note_options,
|
||||||
)
|
)
|
||||||
.ui(ui);
|
.ui(ui);
|
||||||
|
|
||||||
|
|||||||
@@ -11,33 +11,33 @@ use tracing::warn;
|
|||||||
|
|
||||||
use notedeck::{supported_mime_hosted_at_url, Images, MediaCacheType, NoteCache};
|
use notedeck::{supported_mime_hosted_at_url, Images, MediaCacheType, NoteCache};
|
||||||
|
|
||||||
/// Aggregates dependencies to reduce the number of parameters
|
pub struct NoteContents<'a> {
|
||||||
/// passed to inner UI elements, minimizing prop drilling.
|
ndb: &'a Ndb,
|
||||||
pub struct NoteContext<'d> {
|
img_cache: &'a mut Images,
|
||||||
pub ndb: &'d Ndb,
|
note_cache: &'a mut NoteCache,
|
||||||
pub img_cache: &'d mut Images,
|
|
||||||
pub note_cache: &'d mut NoteCache,
|
|
||||||
pub options: NoteOptions,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct NoteContents<'a, 'd> {
|
|
||||||
note_context: &'a mut NoteContext<'d>,
|
|
||||||
txn: &'a Transaction,
|
txn: &'a Transaction,
|
||||||
note: &'a Note<'a>,
|
note: &'a Note<'a>,
|
||||||
|
options: NoteOptions,
|
||||||
action: Option<NoteAction>,
|
action: Option<NoteAction>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'd> NoteContents<'a, 'd> {
|
impl<'a> NoteContents<'a> {
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
note_context: &'a mut NoteContext<'d>,
|
ndb: &'a Ndb,
|
||||||
|
img_cache: &'a mut Images,
|
||||||
|
note_cache: &'a mut NoteCache,
|
||||||
txn: &'a Transaction,
|
txn: &'a Transaction,
|
||||||
note: &'a Note,
|
note: &'a Note,
|
||||||
|
options: ui::note::NoteOptions,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
NoteContents {
|
NoteContents {
|
||||||
note_context,
|
ndb,
|
||||||
|
img_cache,
|
||||||
|
note_cache,
|
||||||
txn,
|
txn,
|
||||||
note,
|
note,
|
||||||
|
options,
|
||||||
action: None,
|
action: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,9 +47,17 @@ impl<'a, 'd> NoteContents<'a, 'd> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl egui::Widget for &mut NoteContents<'_, '_> {
|
impl egui::Widget for &mut NoteContents<'_> {
|
||||||
fn ui(self, ui: &mut egui::Ui) -> egui::Response {
|
fn ui(self, ui: &mut egui::Ui) -> egui::Response {
|
||||||
let result = render_note_contents(ui, self.note_context, self.txn, self.note);
|
let result = render_note_contents(
|
||||||
|
ui,
|
||||||
|
self.ndb,
|
||||||
|
self.img_cache,
|
||||||
|
self.note_cache,
|
||||||
|
self.txn,
|
||||||
|
self.note,
|
||||||
|
self.options,
|
||||||
|
);
|
||||||
self.action = result.action;
|
self.action = result.action;
|
||||||
result.response
|
result.response
|
||||||
}
|
}
|
||||||
@@ -60,15 +68,18 @@ impl egui::Widget for &mut NoteContents<'_, '_> {
|
|||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn render_note_preview(
|
pub fn render_note_preview(
|
||||||
ui: &mut egui::Ui,
|
ui: &mut egui::Ui,
|
||||||
note_context: &mut NoteContext,
|
ndb: &Ndb,
|
||||||
|
note_cache: &mut NoteCache,
|
||||||
|
img_cache: &mut Images,
|
||||||
txn: &Transaction,
|
txn: &Transaction,
|
||||||
id: &[u8; 32],
|
id: &[u8; 32],
|
||||||
parent: NoteKey,
|
parent: NoteKey,
|
||||||
|
note_options: NoteOptions,
|
||||||
) -> NoteResponse {
|
) -> NoteResponse {
|
||||||
#[cfg(feature = "profiling")]
|
#[cfg(feature = "profiling")]
|
||||||
puffin::profile_function!();
|
puffin::profile_function!();
|
||||||
|
|
||||||
let note = if let Ok(note) = note_context.ndb.get_note_by_id(txn, id) {
|
let note = if let Ok(note) = ndb.get_note_by_id(txn, id) {
|
||||||
// TODO: support other preview kinds
|
// TODO: support other preview kinds
|
||||||
if note.kind() == 1 {
|
if note.kind() == 1 {
|
||||||
note
|
note
|
||||||
@@ -101,7 +112,7 @@ pub fn render_note_preview(
|
|||||||
ui.visuals().noninteractive().bg_stroke.color,
|
ui.visuals().noninteractive().bg_stroke.color,
|
||||||
))
|
))
|
||||||
.show(ui, |ui| {
|
.show(ui, |ui| {
|
||||||
ui::NoteView::new(note_context, ¬e)
|
ui::NoteView::new(ndb, note_cache, img_cache, ¬e, note_options)
|
||||||
.actionbar(false)
|
.actionbar(false)
|
||||||
.small_pfp(true)
|
.small_pfp(true)
|
||||||
.wide(true)
|
.wide(true)
|
||||||
@@ -116,23 +127,26 @@ pub fn render_note_preview(
|
|||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn render_note_contents(
|
fn render_note_contents(
|
||||||
ui: &mut egui::Ui,
|
ui: &mut egui::Ui,
|
||||||
note_context: &mut NoteContext,
|
ndb: &Ndb,
|
||||||
|
img_cache: &mut Images,
|
||||||
|
note_cache: &mut NoteCache,
|
||||||
txn: &Transaction,
|
txn: &Transaction,
|
||||||
note: &Note,
|
note: &Note,
|
||||||
|
options: NoteOptions,
|
||||||
) -> NoteResponse {
|
) -> NoteResponse {
|
||||||
#[cfg(feature = "profiling")]
|
#[cfg(feature = "profiling")]
|
||||||
puffin::profile_function!();
|
puffin::profile_function!();
|
||||||
|
|
||||||
let note_key = note.key().expect("todo: implement non-db notes");
|
let note_key = note.key().expect("todo: implement non-db notes");
|
||||||
let selectable = note_context.options.has_selectable_text();
|
let selectable = options.has_selectable_text();
|
||||||
let mut images: Vec<(String, MediaCacheType)> = vec![];
|
let mut images: Vec<(String, MediaCacheType)> = vec![];
|
||||||
let mut note_action: Option<NoteAction> = None;
|
let mut note_action: Option<NoteAction> = None;
|
||||||
let mut inline_note: Option<(&[u8; 32], &str)> = None;
|
let mut inline_note: Option<(&[u8; 32], &str)> = None;
|
||||||
let hide_media = note_context.options.has_hide_media();
|
let hide_media = options.has_hide_media();
|
||||||
let link_color = ui.visuals().hyperlink_color;
|
let link_color = ui.visuals().hyperlink_color;
|
||||||
|
|
||||||
let response = ui.horizontal_wrapped(|ui| {
|
let response = ui.horizontal_wrapped(|ui| {
|
||||||
let blocks = if let Ok(blocks) = note_context.ndb.get_blocks_by_key(txn, note_key) {
|
let blocks = if let Ok(blocks) = ndb.get_blocks_by_key(txn, note_key) {
|
||||||
blocks
|
blocks
|
||||||
} else {
|
} else {
|
||||||
warn!("missing note content blocks? '{}'", note.content());
|
warn!("missing note content blocks? '{}'", note.content());
|
||||||
@@ -146,38 +160,28 @@ fn render_note_contents(
|
|||||||
match block.blocktype() {
|
match block.blocktype() {
|
||||||
BlockType::MentionBech32 => match block.as_mention().unwrap() {
|
BlockType::MentionBech32 => match block.as_mention().unwrap() {
|
||||||
Mention::Profile(profile) => {
|
Mention::Profile(profile) => {
|
||||||
let act = ui::Mention::new(
|
let act = ui::Mention::new(ndb, img_cache, txn, profile.pubkey())
|
||||||
note_context.ndb,
|
.show(ui)
|
||||||
note_context.img_cache,
|
.inner;
|
||||||
txn,
|
|
||||||
profile.pubkey(),
|
|
||||||
)
|
|
||||||
.show(ui)
|
|
||||||
.inner;
|
|
||||||
if act.is_some() {
|
if act.is_some() {
|
||||||
note_action = act;
|
note_action = act;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Mention::Pubkey(npub) => {
|
Mention::Pubkey(npub) => {
|
||||||
let act = ui::Mention::new(
|
let act = ui::Mention::new(ndb, img_cache, txn, npub.pubkey())
|
||||||
note_context.ndb,
|
.show(ui)
|
||||||
note_context.img_cache,
|
.inner;
|
||||||
txn,
|
|
||||||
npub.pubkey(),
|
|
||||||
)
|
|
||||||
.show(ui)
|
|
||||||
.inner;
|
|
||||||
if act.is_some() {
|
if act.is_some() {
|
||||||
note_action = act;
|
note_action = act;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Mention::Note(note) if note_context.options.has_note_previews() => {
|
Mention::Note(note) if options.has_note_previews() => {
|
||||||
inline_note = Some((note.id(), block.as_str()));
|
inline_note = Some((note.id(), block.as_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Mention::Event(note) if note_context.options.has_note_previews() => {
|
Mention::Event(note) if options.has_note_previews() => {
|
||||||
inline_note = Some((note.id(), block.as_str()));
|
inline_note = Some((note.id(), block.as_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,7 +208,7 @@ fn render_note_contents(
|
|||||||
let mut found_supported = || -> bool {
|
let mut found_supported = || -> bool {
|
||||||
let url = block.as_str();
|
let url = block.as_str();
|
||||||
if let Some(cache_type) =
|
if let Some(cache_type) =
|
||||||
supported_mime_hosted_at_url(&mut note_context.img_cache.urls, url)
|
supported_mime_hosted_at_url(&mut img_cache.urls, url)
|
||||||
{
|
{
|
||||||
images.push((url.to_string(), cache_type));
|
images.push((url.to_string(), cache_type));
|
||||||
true
|
true
|
||||||
@@ -225,7 +229,7 @@ fn render_note_contents(
|
|||||||
BlockType::Text => {
|
BlockType::Text => {
|
||||||
#[cfg(feature = "profiling")]
|
#[cfg(feature = "profiling")]
|
||||||
puffin::profile_scope!("text contents");
|
puffin::profile_scope!("text contents");
|
||||||
if note_context.options.has_scramble_text() {
|
if options.has_scramble_text() {
|
||||||
ui.add(egui::Label::new(rot13(block.as_str())).selectable(selectable));
|
ui.add(egui::Label::new(rot13(block.as_str())).selectable(selectable));
|
||||||
} else {
|
} else {
|
||||||
ui.add(egui::Label::new(block.as_str()).selectable(selectable));
|
ui.add(egui::Label::new(block.as_str()).selectable(selectable));
|
||||||
@@ -240,15 +244,15 @@ fn render_note_contents(
|
|||||||
});
|
});
|
||||||
|
|
||||||
let preview_note_action = if let Some((id, _block_str)) = inline_note {
|
let preview_note_action = if let Some((id, _block_str)) = inline_note {
|
||||||
render_note_preview(ui, note_context, txn, id, note_key).action
|
render_note_preview(ui, ndb, note_cache, img_cache, txn, id, note_key, options).action
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
if !images.is_empty() && !note_context.options.has_textmode() {
|
if !images.is_empty() && !options.has_textmode() {
|
||||||
ui.add_space(2.0);
|
ui.add_space(2.0);
|
||||||
let carousel_id = egui::Id::new(("carousel", note.key().expect("expected tx note")));
|
let carousel_id = egui::Id::new(("carousel", note.key().expect("expected tx note")));
|
||||||
image_carousel(ui, note_context.img_cache, images, carousel_id);
|
image_carousel(ui, img_cache, images, carousel_id);
|
||||||
ui.add_space(2.0);
|
ui.add_space(2.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ pub mod reply;
|
|||||||
pub mod reply_description;
|
pub mod reply_description;
|
||||||
|
|
||||||
pub use contents::NoteContents;
|
pub use contents::NoteContents;
|
||||||
use contents::NoteContext;
|
|
||||||
pub use context::{NoteContextButton, NoteContextSelection};
|
pub use context::{NoteContextButton, NoteContextSelection};
|
||||||
pub use options::NoteOptions;
|
pub use options::NoteOptions;
|
||||||
pub use post::{PostAction, PostResponse, PostType, PostView};
|
pub use post::{PostAction, PostResponse, PostType, PostView};
|
||||||
@@ -26,14 +25,17 @@ use egui::emath::{pos2, Vec2};
|
|||||||
use egui::{Id, Label, Pos2, Rect, Response, RichText, Sense};
|
use egui::{Id, Label, Pos2, Rect, Response, RichText, Sense};
|
||||||
use enostr::{NoteId, Pubkey};
|
use enostr::{NoteId, Pubkey};
|
||||||
use nostrdb::{Ndb, Note, NoteKey, Transaction};
|
use nostrdb::{Ndb, Note, NoteKey, Transaction};
|
||||||
use notedeck::{CachedNote, NoteCache, NotedeckTextStyle};
|
use notedeck::{CachedNote, Images, NoteCache, NotedeckTextStyle};
|
||||||
|
|
||||||
use super::profile::preview::one_line_display_name_widget;
|
use super::profile::preview::one_line_display_name_widget;
|
||||||
|
|
||||||
pub struct NoteView<'a, 'd> {
|
pub struct NoteView<'a> {
|
||||||
note_context: &'a mut NoteContext<'d>,
|
ndb: &'a Ndb,
|
||||||
|
note_cache: &'a mut NoteCache,
|
||||||
|
img_cache: &'a mut Images,
|
||||||
parent: Option<NoteKey>,
|
parent: Option<NoteKey>,
|
||||||
note: &'a nostrdb::Note<'a>,
|
note: &'a nostrdb::Note<'a>,
|
||||||
|
flags: NoteOptions,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct NoteResponse {
|
pub struct NoteResponse {
|
||||||
@@ -62,22 +64,31 @@ impl NoteResponse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl View for NoteView<'_, '_> {
|
impl View for NoteView<'_> {
|
||||||
fn ui(&mut self, ui: &mut egui::Ui) {
|
fn ui(&mut self, ui: &mut egui::Ui) {
|
||||||
self.show(ui);
|
self.show(ui);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'd> NoteView<'a, 'd> {
|
impl<'a> NoteView<'a> {
|
||||||
pub fn new(note_context: &'a mut NoteContext<'d>, note: &'a nostrdb::Note<'a>) -> Self {
|
pub fn new(
|
||||||
note_context.options.set_actionbar(true);
|
ndb: &'a Ndb,
|
||||||
note_context.options.set_note_previews(true);
|
note_cache: &'a mut NoteCache,
|
||||||
|
img_cache: &'a mut Images,
|
||||||
|
note: &'a nostrdb::Note<'a>,
|
||||||
|
mut flags: NoteOptions,
|
||||||
|
) -> Self {
|
||||||
|
flags.set_actionbar(true);
|
||||||
|
flags.set_note_previews(true);
|
||||||
|
|
||||||
let parent: Option<NoteKey> = None;
|
let parent: Option<NoteKey> = None;
|
||||||
Self {
|
Self {
|
||||||
note_context,
|
ndb,
|
||||||
|
note_cache,
|
||||||
|
img_cache,
|
||||||
parent,
|
parent,
|
||||||
note,
|
note,
|
||||||
|
flags,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,11 +133,11 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn options(&self) -> NoteOptions {
|
pub fn options(&self) -> NoteOptions {
|
||||||
self.note_context.options
|
self.flags
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn options_mut(&mut self) -> &mut NoteOptions {
|
pub fn options_mut(&mut self) -> &mut NoteOptions {
|
||||||
&mut self.note_context.options
|
&mut self.flags
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parent(mut self, parent: NoteKey) -> Self {
|
pub fn parent(mut self, parent: NoteKey) -> Self {
|
||||||
@@ -139,16 +150,12 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
let txn = self.note.txn().expect("todo: implement non-db notes");
|
let txn = self.note.txn().expect("todo: implement non-db notes");
|
||||||
|
|
||||||
ui.with_layout(egui::Layout::left_to_right(egui::Align::TOP), |ui| {
|
ui.with_layout(egui::Layout::left_to_right(egui::Align::TOP), |ui| {
|
||||||
let profile = self
|
let profile = self.ndb.get_profile_by_pubkey(txn, self.note.pubkey());
|
||||||
.note_context
|
|
||||||
.ndb
|
|
||||||
.get_profile_by_pubkey(txn, self.note.pubkey());
|
|
||||||
|
|
||||||
//ui.horizontal(|ui| {
|
//ui.horizontal(|ui| {
|
||||||
ui.spacing_mut().item_spacing.x = 2.0;
|
ui.spacing_mut().item_spacing.x = 2.0;
|
||||||
|
|
||||||
let cached_note = self
|
let cached_note = self
|
||||||
.note_context
|
|
||||||
.note_cache
|
.note_cache
|
||||||
.cached_note_or_insert_mut(note_key, self.note);
|
.cached_note_or_insert_mut(note_key, self.note);
|
||||||
|
|
||||||
@@ -167,7 +174,14 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
ui.add(&mut NoteContents::new(self.note_context, txn, self.note));
|
ui.add(&mut NoteContents::new(
|
||||||
|
self.ndb,
|
||||||
|
self.img_cache,
|
||||||
|
self.note_cache,
|
||||||
|
txn,
|
||||||
|
self.note,
|
||||||
|
self.flags,
|
||||||
|
));
|
||||||
//});
|
//});
|
||||||
})
|
})
|
||||||
.response
|
.response
|
||||||
@@ -212,17 +226,14 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
anim_speed,
|
anim_speed,
|
||||||
);
|
);
|
||||||
|
|
||||||
ui.put(
|
ui.put(rect, ui::ProfilePic::new(self.img_cache, pic).size(size))
|
||||||
rect,
|
.on_hover_ui_at_pointer(|ui| {
|
||||||
ui::ProfilePic::new(self.note_context.img_cache, pic).size(size),
|
ui.set_max_width(300.0);
|
||||||
)
|
ui.add(ui::ProfilePreview::new(
|
||||||
.on_hover_ui_at_pointer(|ui| {
|
profile.as_ref().unwrap(),
|
||||||
ui.set_max_width(300.0);
|
self.img_cache,
|
||||||
ui.add(ui::ProfilePreview::new(
|
));
|
||||||
profile.as_ref().unwrap(),
|
});
|
||||||
self.note_context.img_cache,
|
|
||||||
));
|
|
||||||
});
|
|
||||||
|
|
||||||
if resp.hovered() || resp.clicked() {
|
if resp.hovered() || resp.clicked() {
|
||||||
ui::show_pointer(ui);
|
ui::show_pointer(ui);
|
||||||
@@ -238,7 +249,7 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
|
|
||||||
ui.put(
|
ui.put(
|
||||||
rect,
|
rect,
|
||||||
ui::ProfilePic::new(self.note_context.img_cache, ui::ProfilePic::no_pfp_url())
|
ui::ProfilePic::new(self.img_cache, ui::ProfilePic::no_pfp_url())
|
||||||
.size(pfp_size),
|
.size(pfp_size),
|
||||||
)
|
)
|
||||||
.interact(sense)
|
.interact(sense)
|
||||||
@@ -251,11 +262,8 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
NoteResponse::new(self.textmode_ui(ui))
|
NoteResponse::new(self.textmode_ui(ui))
|
||||||
} else {
|
} else {
|
||||||
let txn = self.note.txn().expect("txn");
|
let txn = self.note.txn().expect("txn");
|
||||||
if let Some(note_to_repost) = get_reposted_note(self.note_context.ndb, txn, self.note) {
|
if let Some(note_to_repost) = get_reposted_note(self.ndb, txn, self.note) {
|
||||||
let profile = self
|
let profile = self.ndb.get_profile_by_pubkey(txn, self.note.pubkey());
|
||||||
.note_context
|
|
||||||
.ndb
|
|
||||||
.get_profile_by_pubkey(txn, self.note.pubkey());
|
|
||||||
|
|
||||||
let style = NotedeckTextStyle::Small;
|
let style = NotedeckTextStyle::Small;
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
@@ -272,7 +280,7 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
if let Ok(rec) = &profile {
|
if let Ok(rec) = &profile {
|
||||||
resp.on_hover_ui_at_pointer(|ui| {
|
resp.on_hover_ui_at_pointer(|ui| {
|
||||||
ui.set_max_width(300.0);
|
ui.set_max_width(300.0);
|
||||||
ui.add(ui::ProfilePreview::new(rec, self.note_context.img_cache));
|
ui.add(ui::ProfilePreview::new(rec, self.img_cache));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
let color = ui.style().visuals.noninteractive().fg_stroke.color;
|
let color = ui.style().visuals.noninteractive().fg_stroke.color;
|
||||||
@@ -283,7 +291,14 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
.text_style(style.text_style()),
|
.text_style(style.text_style()),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
NoteView::new(self.note_context, ¬e_to_repost).show(ui)
|
NoteView::new(
|
||||||
|
self.ndb,
|
||||||
|
self.note_cache,
|
||||||
|
self.img_cache,
|
||||||
|
¬e_to_repost,
|
||||||
|
self.flags,
|
||||||
|
)
|
||||||
|
.show(ui)
|
||||||
} else {
|
} else {
|
||||||
self.show_standard(ui)
|
self.show_standard(ui)
|
||||||
}
|
}
|
||||||
@@ -337,10 +352,7 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
let mut selected_option: Option<NoteContextSelection> = None;
|
let mut selected_option: Option<NoteContextSelection> = None;
|
||||||
|
|
||||||
let hitbox_id = note_hitbox_id(note_key, self.options(), self.parent);
|
let hitbox_id = note_hitbox_id(note_key, self.options(), self.parent);
|
||||||
let profile = self
|
let profile = self.ndb.get_profile_by_pubkey(txn, self.note.pubkey());
|
||||||
.note_context
|
|
||||||
.ndb
|
|
||||||
.get_profile_by_pubkey(txn, self.note.pubkey());
|
|
||||||
let maybe_hitbox = maybe_note_hitbox(ui, hitbox_id);
|
let maybe_hitbox = maybe_note_hitbox(ui, hitbox_id);
|
||||||
let container_right = {
|
let container_right = {
|
||||||
let r = ui.available_rect_before_wrap();
|
let r = ui.available_rect_before_wrap();
|
||||||
@@ -365,7 +377,7 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
ui.horizontal_centered(|ui| {
|
ui.horizontal_centered(|ui| {
|
||||||
selected_option = NoteView::note_header(
|
selected_option = NoteView::note_header(
|
||||||
ui,
|
ui,
|
||||||
self.note_context.note_cache,
|
self.note_cache,
|
||||||
self.note,
|
self.note,
|
||||||
&profile,
|
&profile,
|
||||||
self.options(),
|
self.options(),
|
||||||
@@ -377,7 +389,6 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let note_reply = self
|
let note_reply = self
|
||||||
.note_context
|
|
||||||
.note_cache
|
.note_cache
|
||||||
.cached_note_or_insert_mut(note_key, self.note)
|
.cached_note_or_insert_mut(note_key, self.note)
|
||||||
.reply
|
.reply
|
||||||
@@ -386,7 +397,15 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
if note_reply.reply().is_some() {
|
if note_reply.reply().is_some() {
|
||||||
let action = ui
|
let action = ui
|
||||||
.horizontal(|ui| {
|
.horizontal(|ui| {
|
||||||
reply_desc(ui, txn, ¬e_reply, self.note_context)
|
reply_desc(
|
||||||
|
ui,
|
||||||
|
txn,
|
||||||
|
¬e_reply,
|
||||||
|
self.ndb,
|
||||||
|
self.img_cache,
|
||||||
|
self.note_cache,
|
||||||
|
self.flags,
|
||||||
|
)
|
||||||
})
|
})
|
||||||
.inner;
|
.inner;
|
||||||
|
|
||||||
@@ -397,7 +416,14 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut contents = NoteContents::new(self.note_context, txn, self.note);
|
let mut contents = NoteContents::new(
|
||||||
|
self.ndb,
|
||||||
|
self.img_cache,
|
||||||
|
self.note_cache,
|
||||||
|
txn,
|
||||||
|
self.note,
|
||||||
|
self.options(),
|
||||||
|
);
|
||||||
|
|
||||||
ui.add(&mut contents);
|
ui.add(&mut contents);
|
||||||
|
|
||||||
@@ -425,7 +451,7 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
ui.with_layout(egui::Layout::top_down(egui::Align::LEFT), |ui| {
|
ui.with_layout(egui::Layout::top_down(egui::Align::LEFT), |ui| {
|
||||||
selected_option = NoteView::note_header(
|
selected_option = NoteView::note_header(
|
||||||
ui,
|
ui,
|
||||||
self.note_context.note_cache,
|
self.note_cache,
|
||||||
self.note,
|
self.note,
|
||||||
&profile,
|
&profile,
|
||||||
self.options(),
|
self.options(),
|
||||||
@@ -436,14 +462,21 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
ui.spacing_mut().item_spacing.x = 2.0;
|
ui.spacing_mut().item_spacing.x = 2.0;
|
||||||
|
|
||||||
let note_reply = self
|
let note_reply = self
|
||||||
.note_context
|
|
||||||
.note_cache
|
.note_cache
|
||||||
.cached_note_or_insert_mut(note_key, self.note)
|
.cached_note_or_insert_mut(note_key, self.note)
|
||||||
.reply
|
.reply
|
||||||
.borrow(self.note.tags());
|
.borrow(self.note.tags());
|
||||||
|
|
||||||
if note_reply.reply().is_some() {
|
if note_reply.reply().is_some() {
|
||||||
let action = reply_desc(ui, txn, ¬e_reply, self.note_context);
|
let action = reply_desc(
|
||||||
|
ui,
|
||||||
|
txn,
|
||||||
|
¬e_reply,
|
||||||
|
self.ndb,
|
||||||
|
self.img_cache,
|
||||||
|
self.note_cache,
|
||||||
|
self.flags,
|
||||||
|
);
|
||||||
|
|
||||||
if action.is_some() {
|
if action.is_some() {
|
||||||
note_action = action;
|
note_action = action;
|
||||||
@@ -451,7 +484,14 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut contents = NoteContents::new(self.note_context, txn, self.note);
|
let mut contents = NoteContents::new(
|
||||||
|
self.ndb,
|
||||||
|
self.img_cache,
|
||||||
|
self.note_cache,
|
||||||
|
txn,
|
||||||
|
self.note,
|
||||||
|
self.options(),
|
||||||
|
);
|
||||||
ui.add(&mut contents);
|
ui.add(&mut contents);
|
||||||
|
|
||||||
if let Some(action) = contents.action() {
|
if let Some(action) = contents.action() {
|
||||||
@@ -472,8 +512,8 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
|
|
||||||
let note_action = if note_hitbox_clicked(ui, hitbox_id, &response.rect, maybe_hitbox) {
|
let note_action = if note_hitbox_clicked(ui, hitbox_id, &response.rect, maybe_hitbox) {
|
||||||
if let Ok(selection) = ThreadSelection::from_note_id(
|
if let Ok(selection) = ThreadSelection::from_note_id(
|
||||||
self.note_context.ndb,
|
self.ndb,
|
||||||
self.note_context.note_cache,
|
self.note_cache,
|
||||||
self.note.txn().unwrap(),
|
self.note.txn().unwrap(),
|
||||||
NoteId::new(*self.note.id()),
|
NoteId::new(*self.note.id()),
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -14,18 +14,21 @@ use egui::{vec2, Frame, Layout, Margin, Pos2, ScrollArea, Sense, TextBuffer};
|
|||||||
use enostr::{FilledKeypair, FullKeypair, NoteId, Pubkey, RelayPool};
|
use enostr::{FilledKeypair, FullKeypair, NoteId, Pubkey, RelayPool};
|
||||||
use nostrdb::{Ndb, Transaction};
|
use nostrdb::{Ndb, Transaction};
|
||||||
|
|
||||||
use notedeck::supported_mime_hosted_at_url;
|
use notedeck::{supported_mime_hosted_at_url, Images, NoteCache};
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
use super::contents::{render_note_preview, NoteContext};
|
use super::contents::render_note_preview;
|
||||||
|
|
||||||
pub struct PostView<'a, 'd> {
|
pub struct PostView<'a> {
|
||||||
note_context: &'a mut NoteContext<'d>,
|
ndb: &'a Ndb,
|
||||||
draft: &'a mut Draft,
|
draft: &'a mut Draft,
|
||||||
post_type: PostType,
|
post_type: PostType,
|
||||||
|
img_cache: &'a mut Images,
|
||||||
|
note_cache: &'a mut NoteCache,
|
||||||
poster: FilledKeypair<'a>,
|
poster: FilledKeypair<'a>,
|
||||||
id_source: Option<egui::Id>,
|
id_source: Option<egui::Id>,
|
||||||
inner_rect: egui::Rect,
|
inner_rect: egui::Rect,
|
||||||
|
note_options: NoteOptions,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@@ -80,23 +83,29 @@ pub struct PostResponse {
|
|||||||
pub edit_response: egui::Response,
|
pub edit_response: egui::Response,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'd> PostView<'a, 'd> {
|
impl<'a> PostView<'a> {
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
note_context: &'a mut NoteContext<'d>,
|
ndb: &'a Ndb,
|
||||||
draft: &'a mut Draft,
|
draft: &'a mut Draft,
|
||||||
post_type: PostType,
|
post_type: PostType,
|
||||||
|
img_cache: &'a mut Images,
|
||||||
|
note_cache: &'a mut NoteCache,
|
||||||
poster: FilledKeypair<'a>,
|
poster: FilledKeypair<'a>,
|
||||||
inner_rect: egui::Rect,
|
inner_rect: egui::Rect,
|
||||||
|
note_options: NoteOptions,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let id_source: Option<egui::Id> = None;
|
let id_source: Option<egui::Id> = None;
|
||||||
PostView {
|
PostView {
|
||||||
note_context,
|
ndb,
|
||||||
draft,
|
draft,
|
||||||
|
img_cache,
|
||||||
|
note_cache,
|
||||||
poster,
|
poster,
|
||||||
id_source,
|
id_source,
|
||||||
post_type,
|
post_type,
|
||||||
inner_rect,
|
inner_rect,
|
||||||
|
note_options,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,21 +121,17 @@ impl<'a, 'd> PostView<'a, 'd> {
|
|||||||
|
|
||||||
// TODO: refactor pfp control to do all of this for us
|
// TODO: refactor pfp control to do all of this for us
|
||||||
let poster_pfp = self
|
let poster_pfp = self
|
||||||
.note_context
|
|
||||||
.ndb
|
.ndb
|
||||||
.get_profile_by_pubkey(txn, self.poster.pubkey.bytes())
|
.get_profile_by_pubkey(txn, self.poster.pubkey.bytes())
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.ok()
|
.ok()
|
||||||
.and_then(|p| {
|
.and_then(|p| Some(ui::ProfilePic::from_profile(self.img_cache, p)?.size(pfp_size)));
|
||||||
Some(ui::ProfilePic::from_profile(self.note_context.img_cache, p)?.size(pfp_size))
|
|
||||||
});
|
|
||||||
|
|
||||||
if let Some(pfp) = poster_pfp {
|
if let Some(pfp) = poster_pfp {
|
||||||
ui.add(pfp);
|
ui.add(pfp);
|
||||||
} else {
|
} else {
|
||||||
ui.add(
|
ui.add(
|
||||||
ui::ProfilePic::new(self.note_context.img_cache, ui::ProfilePic::no_pfp_url())
|
ui::ProfilePic::new(self.img_cache, ui::ProfilePic::no_pfp_url()).size(pfp_size),
|
||||||
.size(pfp_size),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,15 +228,9 @@ impl<'a, 'd> PostView<'a, 'd> {
|
|||||||
hint_rect
|
hint_rect
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Ok(res) = self.note_context.ndb.search_profile(txn, mention_str, 10)
|
if let Ok(res) = self.ndb.search_profile(txn, mention_str, 10) {
|
||||||
{
|
let resp = SearchResultsView::new(self.img_cache, self.ndb, txn, &res)
|
||||||
let resp = SearchResultsView::new(
|
.show_in_rect(hint_rect, ui);
|
||||||
self.note_context.img_cache,
|
|
||||||
self.note_context.ndb,
|
|
||||||
txn,
|
|
||||||
&res,
|
|
||||||
)
|
|
||||||
.show_in_rect(hint_rect, ui);
|
|
||||||
|
|
||||||
match resp {
|
match resp {
|
||||||
ui::search_results::SearchResultsResponse::SelectResult(
|
ui::search_results::SearchResultsResponse::SelectResult(
|
||||||
@@ -239,10 +238,7 @@ impl<'a, 'd> PostView<'a, 'd> {
|
|||||||
) => {
|
) => {
|
||||||
if let Some(hint_index) = selection {
|
if let Some(hint_index) = selection {
|
||||||
if let Some(pk) = res.get(hint_index) {
|
if let Some(pk) = res.get(hint_index) {
|
||||||
let record = self
|
let record = self.ndb.get_profile_by_pubkey(txn, pk);
|
||||||
.note_context
|
|
||||||
.ndb
|
|
||||||
.get_profile_by_pubkey(txn, pk);
|
|
||||||
|
|
||||||
self.draft.buffer.select_mention_and_replace_name(
|
self.draft.buffer.select_mention_and_replace_name(
|
||||||
mention.index,
|
mention.index,
|
||||||
@@ -322,10 +318,13 @@ impl<'a, 'd> PostView<'a, 'd> {
|
|||||||
ui.set_max_width(avail_size.x * 0.8);
|
ui.set_max_width(avail_size.x * 0.8);
|
||||||
render_note_preview(
|
render_note_preview(
|
||||||
ui,
|
ui,
|
||||||
self.note_context,
|
self.ndb,
|
||||||
|
self.note_cache,
|
||||||
|
self.img_cache,
|
||||||
txn,
|
txn,
|
||||||
id.bytes(),
|
id.bytes(),
|
||||||
nostrdb::NoteKey::new(0),
|
nostrdb::NoteKey::new(0),
|
||||||
|
self.note_options,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -405,11 +404,11 @@ impl<'a, 'd> PostView<'a, 'd> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if let Some(cache_type) =
|
if let Some(cache_type) =
|
||||||
supported_mime_hosted_at_url(&mut self.note_context.img_cache.urls, &media.url)
|
supported_mime_hosted_at_url(&mut self.img_cache.urls, &media.url)
|
||||||
{
|
{
|
||||||
render_images(
|
render_images(
|
||||||
ui,
|
ui,
|
||||||
self.note_context.img_cache,
|
self.img_cache,
|
||||||
&media.url,
|
&media.url,
|
||||||
crate::images::ImageType::Content(width, height),
|
crate::images::ImageType::Content(width, height),
|
||||||
cache_type,
|
cache_type,
|
||||||
@@ -712,25 +711,21 @@ mod preview {
|
|||||||
impl App for PostPreview {
|
impl App for PostPreview {
|
||||||
fn update(&mut self, app: &mut AppContext<'_>, ui: &mut egui::Ui) {
|
fn update(&mut self, app: &mut AppContext<'_>, ui: &mut egui::Ui) {
|
||||||
let txn = Transaction::new(app.ndb).expect("txn");
|
let txn = Transaction::new(app.ndb).expect("txn");
|
||||||
let mut note_context = NoteContext {
|
|
||||||
ndb: app.ndb,
|
|
||||||
img_cache: app.img_cache,
|
|
||||||
note_cache: app.note_cache,
|
|
||||||
options: NoteOptions::default(),
|
|
||||||
};
|
|
||||||
|
|
||||||
PostView::new(
|
PostView::new(
|
||||||
&mut note_context,
|
app.ndb,
|
||||||
&mut self.draft,
|
&mut self.draft,
|
||||||
PostType::New,
|
PostType::New,
|
||||||
|
app.img_cache,
|
||||||
|
app.note_cache,
|
||||||
self.poster.to_filled(),
|
self.poster.to_filled(),
|
||||||
ui.available_rect_before_wrap(),
|
ui.available_rect_before_wrap(),
|
||||||
|
NoteOptions::default(),
|
||||||
)
|
)
|
||||||
.ui(&txn, ui);
|
.ui(&txn, ui);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Preview for PostView<'_, '_> {
|
impl Preview for PostView<'_> {
|
||||||
type Prev = PostPreview;
|
type Prev = PostPreview;
|
||||||
|
|
||||||
fn preview(_cfg: PreviewConfig) -> Self::Prev {
|
fn preview(_cfg: PreviewConfig) -> Self::Prev {
|
||||||
|
|||||||
@@ -1,38 +1,49 @@
|
|||||||
use enostr::{FilledKeypair, NoteId};
|
use enostr::{FilledKeypair, NoteId};
|
||||||
|
use nostrdb::Ndb;
|
||||||
|
use notedeck::{Images, NoteCache};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
draft::Draft,
|
draft::Draft,
|
||||||
ui::{self},
|
ui::{self, note::NoteOptions},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{contents::NoteContext, PostResponse, PostType};
|
use super::{PostResponse, PostType};
|
||||||
|
|
||||||
pub struct QuoteRepostView<'a, 'd> {
|
pub struct QuoteRepostView<'a> {
|
||||||
note_context: &'a mut NoteContext<'d>,
|
ndb: &'a Ndb,
|
||||||
poster: FilledKeypair<'a>,
|
poster: FilledKeypair<'a>,
|
||||||
|
note_cache: &'a mut NoteCache,
|
||||||
|
img_cache: &'a mut Images,
|
||||||
draft: &'a mut Draft,
|
draft: &'a mut Draft,
|
||||||
quoting_note: &'a nostrdb::Note<'a>,
|
quoting_note: &'a nostrdb::Note<'a>,
|
||||||
id_source: Option<egui::Id>,
|
id_source: Option<egui::Id>,
|
||||||
inner_rect: egui::Rect,
|
inner_rect: egui::Rect,
|
||||||
|
note_options: NoteOptions,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'd> QuoteRepostView<'a, 'd> {
|
impl<'a> QuoteRepostView<'a> {
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
note_context: &'a mut NoteContext<'d>,
|
ndb: &'a Ndb,
|
||||||
poster: FilledKeypair<'a>,
|
poster: FilledKeypair<'a>,
|
||||||
|
note_cache: &'a mut NoteCache,
|
||||||
|
img_cache: &'a mut Images,
|
||||||
draft: &'a mut Draft,
|
draft: &'a mut Draft,
|
||||||
quoting_note: &'a nostrdb::Note<'a>,
|
quoting_note: &'a nostrdb::Note<'a>,
|
||||||
inner_rect: egui::Rect,
|
inner_rect: egui::Rect,
|
||||||
|
note_options: NoteOptions,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let id_source: Option<egui::Id> = None;
|
let id_source: Option<egui::Id> = None;
|
||||||
QuoteRepostView {
|
QuoteRepostView {
|
||||||
note_context,
|
ndb,
|
||||||
poster,
|
poster,
|
||||||
|
note_cache,
|
||||||
|
img_cache,
|
||||||
draft,
|
draft,
|
||||||
quoting_note,
|
quoting_note,
|
||||||
id_source,
|
id_source,
|
||||||
inner_rect,
|
inner_rect,
|
||||||
|
note_options,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,11 +52,14 @@ impl<'a, 'd> QuoteRepostView<'a, 'd> {
|
|||||||
let quoting_note_id = self.quoting_note.id();
|
let quoting_note_id = self.quoting_note.id();
|
||||||
|
|
||||||
ui::PostView::new(
|
ui::PostView::new(
|
||||||
self.note_context,
|
self.ndb,
|
||||||
self.draft,
|
self.draft,
|
||||||
PostType::Quote(NoteId::new(quoting_note_id.to_owned())),
|
PostType::Quote(NoteId::new(quoting_note_id.to_owned())),
|
||||||
|
self.img_cache,
|
||||||
|
self.note_cache,
|
||||||
self.poster,
|
self.poster,
|
||||||
self.inner_rect,
|
self.inner_rect,
|
||||||
|
self.note_options,
|
||||||
)
|
)
|
||||||
.id_source(id)
|
.id_source(id)
|
||||||
.ui(self.quoting_note.txn().unwrap(), ui)
|
.ui(self.quoting_note.txn().unwrap(), ui)
|
||||||
|
|||||||
@@ -1,36 +1,46 @@
|
|||||||
use crate::draft::Draft;
|
use crate::draft::Draft;
|
||||||
use crate::ui;
|
use crate::ui;
|
||||||
use crate::ui::note::{PostResponse, PostType};
|
use crate::ui::note::{NoteOptions, PostResponse, PostType};
|
||||||
use enostr::{FilledKeypair, NoteId};
|
use enostr::{FilledKeypair, NoteId};
|
||||||
|
use nostrdb::Ndb;
|
||||||
|
|
||||||
use super::contents::NoteContext;
|
use notedeck::{Images, NoteCache};
|
||||||
|
|
||||||
pub struct PostReplyView<'a, 'd> {
|
pub struct PostReplyView<'a> {
|
||||||
note_context: &'a mut NoteContext<'d>,
|
ndb: &'a Ndb,
|
||||||
poster: FilledKeypair<'a>,
|
poster: FilledKeypair<'a>,
|
||||||
|
note_cache: &'a mut NoteCache,
|
||||||
|
img_cache: &'a mut Images,
|
||||||
draft: &'a mut Draft,
|
draft: &'a mut Draft,
|
||||||
note: &'a nostrdb::Note<'a>,
|
note: &'a nostrdb::Note<'a>,
|
||||||
id_source: Option<egui::Id>,
|
id_source: Option<egui::Id>,
|
||||||
inner_rect: egui::Rect,
|
inner_rect: egui::Rect,
|
||||||
|
note_options: NoteOptions,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'd> PostReplyView<'a, 'd> {
|
impl<'a> PostReplyView<'a> {
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
note_context: &'a mut NoteContext<'d>,
|
ndb: &'a Ndb,
|
||||||
poster: FilledKeypair<'a>,
|
poster: FilledKeypair<'a>,
|
||||||
draft: &'a mut Draft,
|
draft: &'a mut Draft,
|
||||||
|
note_cache: &'a mut NoteCache,
|
||||||
|
img_cache: &'a mut Images,
|
||||||
note: &'a nostrdb::Note<'a>,
|
note: &'a nostrdb::Note<'a>,
|
||||||
inner_rect: egui::Rect,
|
inner_rect: egui::Rect,
|
||||||
|
note_options: NoteOptions,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let id_source: Option<egui::Id> = None;
|
let id_source: Option<egui::Id> = None;
|
||||||
PostReplyView {
|
PostReplyView {
|
||||||
note_context,
|
ndb,
|
||||||
poster,
|
poster,
|
||||||
draft,
|
draft,
|
||||||
note,
|
note,
|
||||||
|
note_cache,
|
||||||
|
img_cache,
|
||||||
id_source,
|
id_source,
|
||||||
inner_rect,
|
inner_rect,
|
||||||
|
note_options,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,11 +71,17 @@ impl<'a, 'd> PostReplyView<'a, 'd> {
|
|||||||
egui::Frame::none()
|
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(self.note_context, self.note)
|
ui::NoteView::new(
|
||||||
.actionbar(false)
|
self.ndb,
|
||||||
.medium_pfp(true)
|
self.note_cache,
|
||||||
.options_button(true)
|
self.img_cache,
|
||||||
.show(ui);
|
self.note,
|
||||||
|
self.note_options,
|
||||||
|
)
|
||||||
|
.actionbar(false)
|
||||||
|
.medium_pfp(true)
|
||||||
|
.options_button(true)
|
||||||
|
.show(ui);
|
||||||
});
|
});
|
||||||
|
|
||||||
let id = self.id();
|
let id = self.id();
|
||||||
@@ -74,11 +90,14 @@ impl<'a, 'd> PostReplyView<'a, 'd> {
|
|||||||
|
|
||||||
let post_response = {
|
let post_response = {
|
||||||
ui::PostView::new(
|
ui::PostView::new(
|
||||||
self.note_context,
|
self.ndb,
|
||||||
self.draft,
|
self.draft,
|
||||||
PostType::Reply(NoteId::new(*replying_to)),
|
PostType::Reply(NoteId::new(*replying_to)),
|
||||||
|
self.img_cache,
|
||||||
|
self.note_cache,
|
||||||
self.poster,
|
self.poster,
|
||||||
self.inner_rect,
|
self.inner_rect,
|
||||||
|
self.note_options,
|
||||||
)
|
)
|
||||||
.id_source(id)
|
.id_source(id)
|
||||||
.ui(self.note.txn().unwrap(), ui)
|
.ui(self.note.txn().unwrap(), ui)
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
actionbar::NoteAction,
|
actionbar::NoteAction,
|
||||||
ui::{self},
|
ui::{self, note::NoteOptions},
|
||||||
};
|
};
|
||||||
use egui::{Label, RichText, Sense};
|
use egui::{Label, RichText, Sense};
|
||||||
use nostrdb::{Note, NoteReply, Transaction};
|
use nostrdb::{Ndb, Note, NoteReply, Transaction};
|
||||||
|
use notedeck::{Images, NoteCache};
|
||||||
use super::contents::NoteContext;
|
|
||||||
|
|
||||||
#[must_use = "Please handle the resulting note action"]
|
#[must_use = "Please handle the resulting note action"]
|
||||||
pub fn reply_desc(
|
pub fn reply_desc(
|
||||||
ui: &mut egui::Ui,
|
ui: &mut egui::Ui,
|
||||||
txn: &Transaction,
|
txn: &Transaction,
|
||||||
note_reply: &NoteReply,
|
note_reply: &NoteReply,
|
||||||
note_context: &mut NoteContext,
|
ndb: &Ndb,
|
||||||
|
img_cache: &mut Images,
|
||||||
|
note_cache: &mut NoteCache,
|
||||||
|
note_options: NoteOptions,
|
||||||
) -> Option<NoteAction> {
|
) -> Option<NoteAction> {
|
||||||
#[cfg(feature = "profiling")]
|
#[cfg(feature = "profiling")]
|
||||||
puffin::profile_function!();
|
puffin::profile_function!();
|
||||||
@@ -25,34 +27,37 @@ pub fn reply_desc(
|
|||||||
let link_color = visuals.hyperlink_color;
|
let link_color = visuals.hyperlink_color;
|
||||||
|
|
||||||
// note link renderer helper
|
// note link renderer helper
|
||||||
let note_link =
|
let note_link = |ui: &mut egui::Ui,
|
||||||
|ui: &mut egui::Ui, note_context: &mut NoteContext, text: &str, note: &Note<'_>| {
|
note_cache: &mut NoteCache,
|
||||||
let r = ui.add(
|
img_cache: &mut Images,
|
||||||
Label::new(RichText::new(text).size(size).color(link_color))
|
text: &str,
|
||||||
.sense(Sense::click())
|
note: &Note<'_>| {
|
||||||
.selectable(selectable),
|
let r = ui.add(
|
||||||
);
|
Label::new(RichText::new(text).size(size).color(link_color))
|
||||||
|
.sense(Sense::click())
|
||||||
|
.selectable(selectable),
|
||||||
|
);
|
||||||
|
|
||||||
if r.clicked() {
|
if r.clicked() {
|
||||||
// TODO: jump to note
|
// TODO: jump to note
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.hovered() {
|
if r.hovered() {
|
||||||
r.on_hover_ui_at_pointer(|ui| {
|
r.on_hover_ui_at_pointer(|ui| {
|
||||||
ui.set_max_width(400.0);
|
ui.set_max_width(400.0);
|
||||||
ui::NoteView::new(note_context, note)
|
ui::NoteView::new(ndb, note_cache, img_cache, note, note_options)
|
||||||
.actionbar(false)
|
.actionbar(false)
|
||||||
.wide(true)
|
.wide(true)
|
||||||
.show(ui);
|
.show(ui);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ui.add(Label::new(RichText::new("replying to").size(size).color(color)).selectable(selectable));
|
ui.add(Label::new(RichText::new("replying to").size(size).color(color)).selectable(selectable));
|
||||||
|
|
||||||
let reply = note_reply.reply()?;
|
let reply = note_reply.reply()?;
|
||||||
|
|
||||||
let reply_note = if let Ok(reply_note) = note_context.ndb.get_note_by_id(txn, reply.id) {
|
let reply_note = if let Ok(reply_note) = ndb.get_note_by_id(txn, reply.id) {
|
||||||
reply_note
|
reply_note
|
||||||
} else {
|
} else {
|
||||||
ui.add(Label::new(RichText::new("a note").size(size).color(color)).selectable(selectable));
|
ui.add(Label::new(RichText::new("a note").size(size).color(color)).selectable(selectable));
|
||||||
@@ -61,16 +66,11 @@ pub fn reply_desc(
|
|||||||
|
|
||||||
if note_reply.is_reply_to_root() {
|
if note_reply.is_reply_to_root() {
|
||||||
// We're replying to the root, let's show this
|
// We're replying to the root, let's show this
|
||||||
let action = ui::Mention::new(
|
let action = ui::Mention::new(ndb, img_cache, txn, reply_note.pubkey())
|
||||||
note_context.ndb,
|
.size(size)
|
||||||
note_context.img_cache,
|
.selectable(selectable)
|
||||||
txn,
|
.show(ui)
|
||||||
reply_note.pubkey(),
|
.inner;
|
||||||
)
|
|
||||||
.size(size)
|
|
||||||
.selectable(selectable)
|
|
||||||
.show(ui)
|
|
||||||
.inner;
|
|
||||||
|
|
||||||
if action.is_some() {
|
if action.is_some() {
|
||||||
note_action = action;
|
note_action = action;
|
||||||
@@ -78,23 +78,18 @@ pub fn reply_desc(
|
|||||||
|
|
||||||
ui.add(Label::new(RichText::new("'s").size(size).color(color)).selectable(selectable));
|
ui.add(Label::new(RichText::new("'s").size(size).color(color)).selectable(selectable));
|
||||||
|
|
||||||
note_link(ui, note_context, "thread", &reply_note);
|
note_link(ui, note_cache, img_cache, "thread", &reply_note);
|
||||||
} else if let Some(root) = note_reply.root() {
|
} else if let Some(root) = note_reply.root() {
|
||||||
// replying to another post in a thread, not the root
|
// replying to another post in a thread, not the root
|
||||||
|
|
||||||
if let Ok(root_note) = note_context.ndb.get_note_by_id(txn, root.id) {
|
if let Ok(root_note) = ndb.get_note_by_id(txn, root.id) {
|
||||||
if root_note.pubkey() == reply_note.pubkey() {
|
if root_note.pubkey() == reply_note.pubkey() {
|
||||||
// simply "replying to bob's note" when replying to bob in his thread
|
// simply "replying to bob's note" when replying to bob in his thread
|
||||||
let action = ui::Mention::new(
|
let action = ui::Mention::new(ndb, img_cache, txn, reply_note.pubkey())
|
||||||
note_context.ndb,
|
.size(size)
|
||||||
note_context.img_cache,
|
.selectable(selectable)
|
||||||
txn,
|
.show(ui)
|
||||||
reply_note.pubkey(),
|
.inner;
|
||||||
)
|
|
||||||
.size(size)
|
|
||||||
.selectable(selectable)
|
|
||||||
.show(ui)
|
|
||||||
.inner;
|
|
||||||
|
|
||||||
if action.is_some() {
|
if action.is_some() {
|
||||||
note_action = action;
|
note_action = action;
|
||||||
@@ -104,20 +99,15 @@ pub fn reply_desc(
|
|||||||
Label::new(RichText::new("'s").size(size).color(color)).selectable(selectable),
|
Label::new(RichText::new("'s").size(size).color(color)).selectable(selectable),
|
||||||
);
|
);
|
||||||
|
|
||||||
note_link(ui, note_context, "note", &reply_note);
|
note_link(ui, note_cache, img_cache, "note", &reply_note);
|
||||||
} else {
|
} else {
|
||||||
// replying to bob in alice's thread
|
// replying to bob in alice's thread
|
||||||
|
|
||||||
let action = ui::Mention::new(
|
let action = ui::Mention::new(ndb, img_cache, txn, reply_note.pubkey())
|
||||||
note_context.ndb,
|
.size(size)
|
||||||
note_context.img_cache,
|
.selectable(selectable)
|
||||||
txn,
|
.show(ui)
|
||||||
reply_note.pubkey(),
|
.inner;
|
||||||
)
|
|
||||||
.size(size)
|
|
||||||
.selectable(selectable)
|
|
||||||
.show(ui)
|
|
||||||
.inner;
|
|
||||||
|
|
||||||
if action.is_some() {
|
if action.is_some() {
|
||||||
note_action = action;
|
note_action = action;
|
||||||
@@ -127,22 +117,17 @@ pub fn reply_desc(
|
|||||||
Label::new(RichText::new("'s").size(size).color(color)).selectable(selectable),
|
Label::new(RichText::new("'s").size(size).color(color)).selectable(selectable),
|
||||||
);
|
);
|
||||||
|
|
||||||
note_link(ui, note_context, "note", &reply_note);
|
note_link(ui, note_cache, img_cache, "note", &reply_note);
|
||||||
|
|
||||||
ui.add(
|
ui.add(
|
||||||
Label::new(RichText::new("in").size(size).color(color)).selectable(selectable),
|
Label::new(RichText::new("in").size(size).color(color)).selectable(selectable),
|
||||||
);
|
);
|
||||||
|
|
||||||
let action = ui::Mention::new(
|
let action = ui::Mention::new(ndb, img_cache, txn, root_note.pubkey())
|
||||||
note_context.ndb,
|
.size(size)
|
||||||
note_context.img_cache,
|
.selectable(selectable)
|
||||||
txn,
|
.show(ui)
|
||||||
root_note.pubkey(),
|
.inner;
|
||||||
)
|
|
||||||
.size(size)
|
|
||||||
.selectable(selectable)
|
|
||||||
.show(ui)
|
|
||||||
.inner;
|
|
||||||
|
|
||||||
if action.is_some() {
|
if action.is_some() {
|
||||||
note_action = action;
|
note_action = action;
|
||||||
@@ -152,19 +137,14 @@ pub fn reply_desc(
|
|||||||
Label::new(RichText::new("'s").size(size).color(color)).selectable(selectable),
|
Label::new(RichText::new("'s").size(size).color(color)).selectable(selectable),
|
||||||
);
|
);
|
||||||
|
|
||||||
note_link(ui, note_context, "thread", &root_note);
|
note_link(ui, note_cache, img_cache, "thread", &root_note);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let action = ui::Mention::new(
|
let action = ui::Mention::new(ndb, img_cache, txn, reply_note.pubkey())
|
||||||
note_context.ndb,
|
.size(size)
|
||||||
note_context.img_cache,
|
.selectable(selectable)
|
||||||
txn,
|
.show(ui)
|
||||||
reply_note.pubkey(),
|
.inner;
|
||||||
)
|
|
||||||
.size(size)
|
|
||||||
.selectable(selectable)
|
|
||||||
.show(ui)
|
|
||||||
.inner;
|
|
||||||
|
|
||||||
if action.is_some() {
|
if action.is_some() {
|
||||||
note_action = action;
|
note_action = action;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ pub use edit::EditProfileView;
|
|||||||
use egui::load::TexturePoll;
|
use egui::load::TexturePoll;
|
||||||
use egui::{vec2, Color32, Label, Layout, Rect, RichText, Rounding, ScrollArea, Sense, Stroke};
|
use egui::{vec2, Color32, Label, Layout, Rect, RichText, Rounding, ScrollArea, Sense, Stroke};
|
||||||
use enostr::Pubkey;
|
use enostr::Pubkey;
|
||||||
use nostrdb::{ProfileRecord, Transaction};
|
use nostrdb::{Ndb, ProfileRecord, Transaction};
|
||||||
pub use picture::ProfilePic;
|
pub use picture::ProfilePic;
|
||||||
pub use preview::ProfilePreview;
|
pub use preview::ProfilePreview;
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
@@ -16,22 +16,26 @@ use crate::{
|
|||||||
colors, images,
|
colors, images,
|
||||||
profile::get_display_name,
|
profile::get_display_name,
|
||||||
timeline::{TimelineCache, TimelineKind},
|
timeline::{TimelineCache, TimelineKind},
|
||||||
ui::timeline::{tabs_ui, TimelineTabView},
|
ui::{
|
||||||
|
note::NoteOptions,
|
||||||
|
timeline::{tabs_ui, TimelineTabView},
|
||||||
|
},
|
||||||
NostrName,
|
NostrName,
|
||||||
};
|
};
|
||||||
|
|
||||||
use notedeck::{Accounts, MuteFun, NotedeckTextStyle, UnknownIds};
|
use notedeck::{Accounts, Images, MuteFun, NoteCache, NotedeckTextStyle, UnknownIds};
|
||||||
|
|
||||||
use super::note::contents::NoteContext;
|
pub struct ProfileView<'a> {
|
||||||
|
|
||||||
pub struct ProfileView<'a, 'd> {
|
|
||||||
pubkey: &'a Pubkey,
|
pubkey: &'a Pubkey,
|
||||||
accounts: &'a Accounts,
|
accounts: &'a Accounts,
|
||||||
col_id: usize,
|
col_id: usize,
|
||||||
timeline_cache: &'a mut TimelineCache,
|
timeline_cache: &'a mut TimelineCache,
|
||||||
|
note_options: NoteOptions,
|
||||||
|
ndb: &'a Ndb,
|
||||||
|
note_cache: &'a mut NoteCache,
|
||||||
|
img_cache: &'a mut Images,
|
||||||
unknown_ids: &'a mut UnknownIds,
|
unknown_ids: &'a mut UnknownIds,
|
||||||
is_muted: &'a MuteFun,
|
is_muted: &'a MuteFun,
|
||||||
note_context: &'a mut NoteContext<'d>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum ProfileViewAction {
|
pub enum ProfileViewAction {
|
||||||
@@ -39,25 +43,31 @@ pub enum ProfileViewAction {
|
|||||||
Note(NoteAction),
|
Note(NoteAction),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'd> ProfileView<'a, 'd> {
|
impl<'a> ProfileView<'a> {
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
pubkey: &'a Pubkey,
|
pubkey: &'a Pubkey,
|
||||||
accounts: &'a Accounts,
|
accounts: &'a Accounts,
|
||||||
col_id: usize,
|
col_id: usize,
|
||||||
timeline_cache: &'a mut TimelineCache,
|
timeline_cache: &'a mut TimelineCache,
|
||||||
|
ndb: &'a Ndb,
|
||||||
|
note_cache: &'a mut NoteCache,
|
||||||
|
img_cache: &'a mut Images,
|
||||||
unknown_ids: &'a mut UnknownIds,
|
unknown_ids: &'a mut UnknownIds,
|
||||||
is_muted: &'a MuteFun,
|
is_muted: &'a MuteFun,
|
||||||
note_context: &'a mut NoteContext<'d>,
|
note_options: NoteOptions,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
ProfileView {
|
ProfileView {
|
||||||
pubkey,
|
pubkey,
|
||||||
accounts,
|
accounts,
|
||||||
col_id,
|
col_id,
|
||||||
timeline_cache,
|
timeline_cache,
|
||||||
|
ndb,
|
||||||
|
note_cache,
|
||||||
|
img_cache,
|
||||||
unknown_ids,
|
unknown_ids,
|
||||||
|
note_options,
|
||||||
is_muted,
|
is_muted,
|
||||||
note_context,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,12 +78,8 @@ impl<'a, 'd> ProfileView<'a, 'd> {
|
|||||||
.id_salt(scroll_id)
|
.id_salt(scroll_id)
|
||||||
.show(ui, |ui| {
|
.show(ui, |ui| {
|
||||||
let mut action = None;
|
let mut action = None;
|
||||||
let txn = Transaction::new(self.note_context.ndb).expect("txn");
|
let txn = Transaction::new(self.ndb).expect("txn");
|
||||||
if let Ok(profile) = self
|
if let Ok(profile) = self.ndb.get_profile_by_pubkey(&txn, self.pubkey.bytes()) {
|
||||||
.note_context
|
|
||||||
.ndb
|
|
||||||
.get_profile_by_pubkey(&txn, self.pubkey.bytes())
|
|
||||||
{
|
|
||||||
if self.profile_body(ui, profile) {
|
if self.profile_body(ui, profile) {
|
||||||
action = Some(ProfileViewAction::EditProfile);
|
action = Some(ProfileViewAction::EditProfile);
|
||||||
}
|
}
|
||||||
@@ -81,8 +87,8 @@ impl<'a, 'd> ProfileView<'a, 'd> {
|
|||||||
let profile_timeline = self
|
let profile_timeline = self
|
||||||
.timeline_cache
|
.timeline_cache
|
||||||
.notes(
|
.notes(
|
||||||
self.note_context.ndb,
|
self.ndb,
|
||||||
self.note_context.note_cache,
|
self.note_cache,
|
||||||
&txn,
|
&txn,
|
||||||
&TimelineKind::Profile(*self.pubkey),
|
&TimelineKind::Profile(*self.pubkey),
|
||||||
)
|
)
|
||||||
@@ -94,10 +100,10 @@ impl<'a, 'd> ProfileView<'a, 'd> {
|
|||||||
let reversed = false;
|
let reversed = false;
|
||||||
// poll for new notes and insert them into our existing notes
|
// poll for new notes and insert them into our existing notes
|
||||||
if let Err(e) = profile_timeline.poll_notes_into_view(
|
if let Err(e) = profile_timeline.poll_notes_into_view(
|
||||||
self.note_context.ndb,
|
self.ndb,
|
||||||
&txn,
|
&txn,
|
||||||
self.unknown_ids,
|
self.unknown_ids,
|
||||||
self.note_context.note_cache,
|
self.note_cache,
|
||||||
reversed,
|
reversed,
|
||||||
) {
|
) {
|
||||||
error!("Profile::poll_notes_into_view: {e}");
|
error!("Profile::poll_notes_into_view: {e}");
|
||||||
@@ -106,9 +112,12 @@ impl<'a, 'd> ProfileView<'a, 'd> {
|
|||||||
if let Some(note_action) = TimelineTabView::new(
|
if let Some(note_action) = TimelineTabView::new(
|
||||||
profile_timeline.current_view(),
|
profile_timeline.current_view(),
|
||||||
reversed,
|
reversed,
|
||||||
|
self.note_options,
|
||||||
&txn,
|
&txn,
|
||||||
|
self.ndb,
|
||||||
|
self.note_cache,
|
||||||
|
self.img_cache,
|
||||||
self.is_muted,
|
self.is_muted,
|
||||||
self.note_context,
|
|
||||||
)
|
)
|
||||||
.show(ui)
|
.show(ui)
|
||||||
{
|
{
|
||||||
@@ -140,12 +149,9 @@ impl<'a, 'd> ProfileView<'a, 'd> {
|
|||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.put(
|
ui.put(
|
||||||
pfp_rect,
|
pfp_rect,
|
||||||
ProfilePic::new(
|
ProfilePic::new(self.img_cache, get_profile_url(Some(&profile)))
|
||||||
self.note_context.img_cache,
|
.size(size)
|
||||||
get_profile_url(Some(&profile)),
|
.border(ProfilePic::border_stroke(ui)),
|
||||||
)
|
|
||||||
.size(size)
|
|
||||||
.border(ProfilePic::border_stroke(ui)),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if ui.add(copy_key_widget(&pfp_rect)).clicked() {
|
if ui.add(copy_key_widget(&pfp_rect)).clicked() {
|
||||||
|
|||||||
@@ -1,40 +1,50 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
actionbar::NoteAction,
|
actionbar::NoteAction,
|
||||||
timeline::{ThreadSelection, TimelineCache, TimelineKind},
|
timeline::{ThreadSelection, TimelineCache, TimelineKind},
|
||||||
|
ui::note::NoteOptions,
|
||||||
};
|
};
|
||||||
|
|
||||||
use nostrdb::Transaction;
|
use nostrdb::{Ndb, Transaction};
|
||||||
use notedeck::{MuteFun, RootNoteId, UnknownIds};
|
use notedeck::{Images, MuteFun, NoteCache, RootNoteId, UnknownIds};
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
use super::{note::contents::NoteContext, timeline::TimelineTabView};
|
use super::timeline::TimelineTabView;
|
||||||
|
|
||||||
pub struct ThreadView<'a, 'd> {
|
pub struct ThreadView<'a> {
|
||||||
timeline_cache: &'a mut TimelineCache,
|
timeline_cache: &'a mut TimelineCache,
|
||||||
|
ndb: &'a Ndb,
|
||||||
|
note_cache: &'a mut NoteCache,
|
||||||
unknown_ids: &'a mut UnknownIds,
|
unknown_ids: &'a mut UnknownIds,
|
||||||
|
img_cache: &'a mut Images,
|
||||||
selected_note_id: &'a [u8; 32],
|
selected_note_id: &'a [u8; 32],
|
||||||
|
note_options: NoteOptions,
|
||||||
id_source: egui::Id,
|
id_source: egui::Id,
|
||||||
is_muted: &'a MuteFun,
|
is_muted: &'a MuteFun,
|
||||||
note_context: &'a mut NoteContext<'d>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'd> ThreadView<'a, 'd> {
|
impl<'a> ThreadView<'a> {
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
timeline_cache: &'a mut TimelineCache,
|
timeline_cache: &'a mut TimelineCache,
|
||||||
|
ndb: &'a Ndb,
|
||||||
|
note_cache: &'a mut NoteCache,
|
||||||
unknown_ids: &'a mut UnknownIds,
|
unknown_ids: &'a mut UnknownIds,
|
||||||
|
img_cache: &'a mut Images,
|
||||||
selected_note_id: &'a [u8; 32],
|
selected_note_id: &'a [u8; 32],
|
||||||
|
note_options: NoteOptions,
|
||||||
is_muted: &'a MuteFun,
|
is_muted: &'a MuteFun,
|
||||||
note_context: &'a mut NoteContext<'d>,
|
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let id_source = egui::Id::new("threadscroll_threadview");
|
let id_source = egui::Id::new("threadscroll_threadview");
|
||||||
ThreadView {
|
ThreadView {
|
||||||
timeline_cache,
|
timeline_cache,
|
||||||
|
ndb,
|
||||||
|
note_cache,
|
||||||
unknown_ids,
|
unknown_ids,
|
||||||
|
img_cache,
|
||||||
selected_note_id,
|
selected_note_id,
|
||||||
|
note_options,
|
||||||
id_source,
|
id_source,
|
||||||
is_muted,
|
is_muted,
|
||||||
note_context,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +54,7 @@ impl<'a, 'd> ThreadView<'a, 'd> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn ui(&mut self, ui: &mut egui::Ui) -> Option<NoteAction> {
|
pub fn ui(&mut self, ui: &mut egui::Ui) -> Option<NoteAction> {
|
||||||
let txn = Transaction::new(self.note_context.ndb).expect("txn");
|
let txn = Transaction::new(self.ndb).expect("txn");
|
||||||
|
|
||||||
ui.label(
|
ui.label(
|
||||||
egui::RichText::new("Threads ALPHA! It's not done. Things will be broken.")
|
egui::RichText::new("Threads ALPHA! It's not done. Things will be broken.")
|
||||||
@@ -57,25 +67,21 @@ impl<'a, 'd> ThreadView<'a, 'd> {
|
|||||||
.auto_shrink([false, false])
|
.auto_shrink([false, false])
|
||||||
.scroll_bar_visibility(egui::scroll_area::ScrollBarVisibility::AlwaysVisible)
|
.scroll_bar_visibility(egui::scroll_area::ScrollBarVisibility::AlwaysVisible)
|
||||||
.show(ui, |ui| {
|
.show(ui, |ui| {
|
||||||
let root_id = match RootNoteId::new(
|
let root_id =
|
||||||
self.note_context.ndb,
|
match RootNoteId::new(self.ndb, self.note_cache, &txn, self.selected_note_id) {
|
||||||
self.note_context.note_cache,
|
Ok(root_id) => root_id,
|
||||||
&txn,
|
|
||||||
self.selected_note_id,
|
|
||||||
) {
|
|
||||||
Ok(root_id) => root_id,
|
|
||||||
|
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
ui.label(format!("Error loading thread: {:?}", err));
|
ui.label(format!("Error loading thread: {:?}", err));
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let thread_timeline = self
|
let thread_timeline = self
|
||||||
.timeline_cache
|
.timeline_cache
|
||||||
.notes(
|
.notes(
|
||||||
self.note_context.ndb,
|
self.ndb,
|
||||||
self.note_context.note_cache,
|
self.note_cache,
|
||||||
&txn,
|
&txn,
|
||||||
&TimelineKind::Thread(ThreadSelection::from_root_id(root_id.to_owned())),
|
&TimelineKind::Thread(ThreadSelection::from_root_id(root_id.to_owned())),
|
||||||
)
|
)
|
||||||
@@ -86,10 +92,10 @@ impl<'a, 'd> ThreadView<'a, 'd> {
|
|||||||
let reversed = true;
|
let reversed = true;
|
||||||
// poll for new notes and insert them into our existing notes
|
// poll for new notes and insert them into our existing notes
|
||||||
if let Err(err) = thread_timeline.poll_notes_into_view(
|
if let Err(err) = thread_timeline.poll_notes_into_view(
|
||||||
self.note_context.ndb,
|
self.ndb,
|
||||||
&txn,
|
&txn,
|
||||||
self.unknown_ids,
|
self.unknown_ids,
|
||||||
self.note_context.note_cache,
|
self.note_cache,
|
||||||
reversed,
|
reversed,
|
||||||
) {
|
) {
|
||||||
error!("error polling notes into thread timeline: {err}");
|
error!("error polling notes into thread timeline: {err}");
|
||||||
@@ -98,9 +104,12 @@ impl<'a, 'd> ThreadView<'a, 'd> {
|
|||||||
TimelineTabView::new(
|
TimelineTabView::new(
|
||||||
thread_timeline.current_view(),
|
thread_timeline.current_view(),
|
||||||
true,
|
true,
|
||||||
|
self.note_options,
|
||||||
&txn,
|
&txn,
|
||||||
|
self.ndb,
|
||||||
|
self.note_cache,
|
||||||
|
self.img_cache,
|
||||||
self.is_muted,
|
self.is_muted,
|
||||||
self.note_context,
|
|
||||||
)
|
)
|
||||||
.show(ui)
|
.show(ui)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -5,52 +5,64 @@ use crate::timeline::TimelineTab;
|
|||||||
use crate::{
|
use crate::{
|
||||||
timeline::{TimelineCache, TimelineKind, ViewFilter},
|
timeline::{TimelineCache, TimelineKind, ViewFilter},
|
||||||
ui,
|
ui,
|
||||||
|
ui::note::NoteOptions,
|
||||||
};
|
};
|
||||||
use egui::containers::scroll_area::ScrollBarVisibility;
|
use egui::containers::scroll_area::ScrollBarVisibility;
|
||||||
use egui::{vec2, Direction, Layout, Pos2, Stroke};
|
use egui::{vec2, Direction, Layout, Pos2, Stroke};
|
||||||
use egui_tabs::TabColor;
|
use egui_tabs::TabColor;
|
||||||
use nostrdb::Transaction;
|
use nostrdb::{Ndb, Transaction};
|
||||||
use notedeck::note::root_note_id_from_selected_id;
|
use notedeck::note::root_note_id_from_selected_id;
|
||||||
use notedeck::MuteFun;
|
use notedeck::{Images, MuteFun, NoteCache};
|
||||||
use tracing::{error, warn};
|
use tracing::{error, warn};
|
||||||
|
|
||||||
use super::anim::{AnimationHelper, ICON_EXPANSION_MULTIPLE};
|
use super::anim::{AnimationHelper, ICON_EXPANSION_MULTIPLE};
|
||||||
use super::note::contents::NoteContext;
|
|
||||||
|
|
||||||
pub struct TimelineView<'a, 'd> {
|
pub struct TimelineView<'a> {
|
||||||
timeline_id: &'a TimelineKind,
|
timeline_id: &'a TimelineKind,
|
||||||
timeline_cache: &'a mut TimelineCache,
|
timeline_cache: &'a mut TimelineCache,
|
||||||
|
ndb: &'a Ndb,
|
||||||
|
note_cache: &'a mut NoteCache,
|
||||||
|
img_cache: &'a mut Images,
|
||||||
|
note_options: NoteOptions,
|
||||||
reverse: bool,
|
reverse: bool,
|
||||||
is_muted: &'a MuteFun,
|
is_muted: &'a MuteFun,
|
||||||
note_context: &'a mut NoteContext<'d>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'd> TimelineView<'a, 'd> {
|
impl<'a> TimelineView<'a> {
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
timeline_id: &'a TimelineKind,
|
timeline_id: &'a TimelineKind,
|
||||||
timeline_cache: &'a mut TimelineCache,
|
timeline_cache: &'a mut TimelineCache,
|
||||||
|
ndb: &'a Ndb,
|
||||||
|
note_cache: &'a mut NoteCache,
|
||||||
|
img_cache: &'a mut Images,
|
||||||
|
note_options: NoteOptions,
|
||||||
is_muted: &'a MuteFun,
|
is_muted: &'a MuteFun,
|
||||||
note_context: &'a mut NoteContext<'d>,
|
) -> TimelineView<'a> {
|
||||||
) -> Self {
|
|
||||||
let reverse = false;
|
let reverse = false;
|
||||||
TimelineView {
|
TimelineView {
|
||||||
|
ndb,
|
||||||
timeline_id,
|
timeline_id,
|
||||||
timeline_cache,
|
timeline_cache,
|
||||||
|
note_cache,
|
||||||
|
img_cache,
|
||||||
reverse,
|
reverse,
|
||||||
|
note_options,
|
||||||
is_muted,
|
is_muted,
|
||||||
note_context,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ui(&mut self, ui: &mut egui::Ui) -> Option<NoteAction> {
|
pub fn ui(&mut self, ui: &mut egui::Ui) -> Option<NoteAction> {
|
||||||
timeline_ui(
|
timeline_ui(
|
||||||
ui,
|
ui,
|
||||||
|
self.ndb,
|
||||||
self.timeline_id,
|
self.timeline_id,
|
||||||
self.timeline_cache,
|
self.timeline_cache,
|
||||||
|
self.note_cache,
|
||||||
|
self.img_cache,
|
||||||
self.reverse,
|
self.reverse,
|
||||||
|
self.note_options,
|
||||||
self.is_muted,
|
self.is_muted,
|
||||||
self.note_context,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,11 +75,14 @@ impl<'a, 'd> TimelineView<'a, 'd> {
|
|||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn timeline_ui(
|
fn timeline_ui(
|
||||||
ui: &mut egui::Ui,
|
ui: &mut egui::Ui,
|
||||||
|
ndb: &Ndb,
|
||||||
timeline_id: &TimelineKind,
|
timeline_id: &TimelineKind,
|
||||||
timeline_cache: &mut TimelineCache,
|
timeline_cache: &mut TimelineCache,
|
||||||
|
note_cache: &mut NoteCache,
|
||||||
|
img_cache: &mut Images,
|
||||||
reversed: bool,
|
reversed: bool,
|
||||||
|
note_options: NoteOptions,
|
||||||
is_muted: &MuteFun,
|
is_muted: &MuteFun,
|
||||||
note_context: &mut NoteContext,
|
|
||||||
) -> Option<NoteAction> {
|
) -> Option<NoteAction> {
|
||||||
//padding(4.0, ui, |ui| ui.heading("Notifications"));
|
//padding(4.0, ui, |ui| ui.heading("Notifications"));
|
||||||
/*
|
/*
|
||||||
@@ -136,14 +151,16 @@ fn timeline_ui(
|
|||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
|
|
||||||
let txn = Transaction::new(note_context.ndb).expect("failed to create txn");
|
let txn = Transaction::new(ndb).expect("failed to create txn");
|
||||||
|
|
||||||
TimelineTabView::new(
|
TimelineTabView::new(
|
||||||
timeline.current_view(),
|
timeline.current_view(),
|
||||||
reversed,
|
reversed,
|
||||||
|
note_options,
|
||||||
&txn,
|
&txn,
|
||||||
|
ndb,
|
||||||
|
note_cache,
|
||||||
|
img_cache,
|
||||||
is_muted,
|
is_muted,
|
||||||
note_context,
|
|
||||||
)
|
)
|
||||||
.show(ui)
|
.show(ui)
|
||||||
});
|
});
|
||||||
@@ -298,29 +315,38 @@ fn shrink_range_to_width(range: egui::Rangef, width: f32) -> egui::Rangef {
|
|||||||
egui::Rangef::new(min, max)
|
egui::Rangef::new(min, max)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct TimelineTabView<'a, 'd> {
|
pub struct TimelineTabView<'a> {
|
||||||
tab: &'a TimelineTab,
|
tab: &'a TimelineTab,
|
||||||
reversed: bool,
|
reversed: bool,
|
||||||
|
note_options: NoteOptions,
|
||||||
txn: &'a Transaction,
|
txn: &'a Transaction,
|
||||||
|
ndb: &'a Ndb,
|
||||||
|
note_cache: &'a mut NoteCache,
|
||||||
|
img_cache: &'a mut Images,
|
||||||
is_muted: &'a MuteFun,
|
is_muted: &'a MuteFun,
|
||||||
note_context: &'a mut NoteContext<'d>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'd> TimelineTabView<'a, 'd> {
|
impl<'a> TimelineTabView<'a> {
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
tab: &'a TimelineTab,
|
tab: &'a TimelineTab,
|
||||||
reversed: bool,
|
reversed: bool,
|
||||||
|
note_options: NoteOptions,
|
||||||
txn: &'a Transaction,
|
txn: &'a Transaction,
|
||||||
|
ndb: &'a Ndb,
|
||||||
|
note_cache: &'a mut NoteCache,
|
||||||
|
img_cache: &'a mut Images,
|
||||||
is_muted: &'a MuteFun,
|
is_muted: &'a MuteFun,
|
||||||
note_context: &'a mut NoteContext<'d>,
|
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
tab,
|
tab,
|
||||||
reversed,
|
reversed,
|
||||||
txn,
|
txn,
|
||||||
|
note_options,
|
||||||
|
ndb,
|
||||||
|
note_cache,
|
||||||
|
img_cache,
|
||||||
is_muted,
|
is_muted,
|
||||||
note_context,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,21 +371,17 @@ impl<'a, 'd> TimelineTabView<'a, 'd> {
|
|||||||
|
|
||||||
let note_key = self.tab.notes[ind].key;
|
let note_key = self.tab.notes[ind].key;
|
||||||
|
|
||||||
let note =
|
let note = if let Ok(note) = self.ndb.get_note_by_key(self.txn, note_key) {
|
||||||
if let Ok(note) = self.note_context.ndb.get_note_by_key(self.txn, note_key) {
|
note
|
||||||
note
|
} else {
|
||||||
} else {
|
warn!("failed to query note {:?}", note_key);
|
||||||
warn!("failed to query note {:?}", note_key);
|
return 0;
|
||||||
return 0;
|
};
|
||||||
};
|
|
||||||
|
|
||||||
// should we mute the thread? we might not have it!
|
// should we mute the thread? we might not have it!
|
||||||
let muted = if let Ok(root_id) = root_note_id_from_selected_id(
|
let muted = if let Ok(root_id) =
|
||||||
self.note_context.ndb,
|
root_note_id_from_selected_id(self.ndb, self.note_cache, self.txn, note.id())
|
||||||
self.note_context.note_cache,
|
{
|
||||||
self.txn,
|
|
||||||
note.id(),
|
|
||||||
) {
|
|
||||||
is_muted(¬e, root_id.bytes())
|
is_muted(¬e, root_id.bytes())
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
@@ -367,7 +389,14 @@ impl<'a, 'd> TimelineTabView<'a, 'd> {
|
|||||||
|
|
||||||
if !muted {
|
if !muted {
|
||||||
ui::padding(8.0, ui, |ui| {
|
ui::padding(8.0, ui, |ui| {
|
||||||
let resp = ui::NoteView::new(self.note_context, ¬e).show(ui);
|
let resp = ui::NoteView::new(
|
||||||
|
self.ndb,
|
||||||
|
self.note_cache,
|
||||||
|
self.img_cache,
|
||||||
|
¬e,
|
||||||
|
self.note_options,
|
||||||
|
)
|
||||||
|
.show(ui);
|
||||||
|
|
||||||
if let Some(note_action) = resp.action {
|
if let Some(note_action) = resp.action {
|
||||||
action = Some(note_action)
|
action = Some(note_action)
|
||||||
|
|||||||
Reference in New Issue
Block a user