introduce NoteContext

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2025-03-07 17:02:02 -05:00
parent d85c6043b7
commit a9f473e3c9
12 changed files with 368 additions and 430 deletions

View File

@@ -2,19 +2,19 @@ use crate::{
nav::RenderNavAction,
profile::ProfileAction,
timeline::{TimelineCache, TimelineKind},
ui::{self, note::NoteOptions, profile::ProfileView},
ui::{
self,
note::{contents::NoteContext, NoteOptions},
profile::ProfileView,
},
};
use enostr::Pubkey;
use nostrdb::Ndb;
use notedeck::{Accounts, Images, MuteFun, NoteCache, UnknownIds};
use notedeck::{Accounts, MuteFun, UnknownIds};
#[allow(clippy::too_many_arguments)]
pub fn render_timeline_route(
ndb: &Ndb,
img_cache: &mut Images,
unknown_ids: &mut UnknownIds,
note_cache: &mut NoteCache,
timeline_cache: &mut TimelineCache,
accounts: &mut Accounts,
kind: &TimelineKind,
@@ -22,6 +22,7 @@ pub fn render_timeline_route(
mut note_options: NoteOptions,
depth: usize,
ui: &mut egui::Ui,
note_context: &mut NoteContext,
) -> Option<RenderNavAction> {
if kind == &TimelineKind::Universe {
note_options.set_hide_media(true);
@@ -38,11 +39,9 @@ pub fn render_timeline_route(
let note_action = ui::TimelineView::new(
kind,
timeline_cache,
ndb,
note_cache,
img_cache,
note_options,
&accounts.mutefun(),
note_context,
note_options,
)
.ui(ui);
@@ -54,26 +53,22 @@ pub fn render_timeline_route(
render_profile_route(
pubkey,
accounts,
ndb,
timeline_cache,
img_cache,
note_cache,
unknown_ids,
col,
ui,
&accounts.mutefun(),
note_options,
note_context,
)
} else {
// we render profiles like timelines if they are at the root
let note_action = ui::TimelineView::new(
kind,
timeline_cache,
ndb,
note_cache,
img_cache,
note_options,
&accounts.mutefun(),
note_context,
note_options,
)
.ui(ui);
@@ -83,13 +78,11 @@ pub fn render_timeline_route(
TimelineKind::Thread(id) => ui::ThreadView::new(
timeline_cache,
ndb,
note_cache,
unknown_ids,
img_cache,
id.selected_or_root(),
note_options,
&accounts.mutefun(),
note_context,
)
.id_source(egui::Id::new(("threadscroll", col)))
.ui(ui)
@@ -101,27 +94,23 @@ pub fn render_timeline_route(
pub fn render_profile_route(
pubkey: &Pubkey,
accounts: &Accounts,
ndb: &Ndb,
timeline_cache: &mut TimelineCache,
img_cache: &mut Images,
note_cache: &mut NoteCache,
unknown_ids: &mut UnknownIds,
col: usize,
ui: &mut egui::Ui,
is_muted: &MuteFun,
note_options: NoteOptions,
note_context: &mut NoteContext,
) -> Option<RenderNavAction> {
let action = ProfileView::new(
pubkey,
accounts,
col,
timeline_cache,
ndb,
note_cache,
img_cache,
note_options,
unknown_ids,
is_muted,
note_options,
note_context,
)
.ui(ui);