notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit 5d4e795de84dc9f0067a8e28a3c790e19f2b220b
parent 5bdb308b410d06cda72806b107a0caf4360704c4
Author: kernelkind <kernelkind@gmail.com>
Date:   Tue, 10 Feb 2026 17:26:10 -0500

feat(outbox): add `NotedeckRef`

for upcoming borrow issues in integration

Signed-off-by: kernelkind <kernelkind@gmail.com>

Diffstat:
Mcrates/notedeck/src/app.rs | 92++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------
Mcrates/notedeck_chrome/src/chrome.rs | 12+++++++-----
2 files changed, 63 insertions(+), 41 deletions(-)

diff --git a/crates/notedeck/src/app.rs b/crates/notedeck/src/app.rs @@ -354,22 +354,6 @@ impl Notedeck { ); } - /// ensure we recognized all the arguments - pub fn check_args(&self, other_app_args: &BTreeSet<String>) -> Result<(), Error> { - let completely_unrecognized: Vec<String> = self - .unrecognized_args() - .intersection(other_app_args) - .cloned() - .collect(); - if !completely_unrecognized.is_empty() { - let err = format!("Unrecognized arguments: {completely_unrecognized:?}"); - tracing::error!("{}", &err); - return Err(Error::Generic(err)); - } - - Ok(()) - } - #[inline] pub fn options(&self) -> NotedeckOptions { self.args.options @@ -385,26 +369,35 @@ impl Notedeck { } pub fn app_context(&mut self) -> AppContext<'_> { - AppContext { - ndb: &mut self.ndb, - img_cache: &mut self.img_cache, - unknown_ids: &mut self.unknown_ids, - pool: &mut self.pool, - note_cache: &mut self.note_cache, - accounts: &mut self.accounts, - global_wallet: &mut self.global_wallet, - path: &self.path, - args: &self.args, - settings: &mut self.settings, - clipboard: &mut self.clipboard, - zaps: &mut self.zaps, - frame_history: &mut self.frame_history, - job_pool: &mut self.job_pool, - media_jobs: &mut self.media_jobs, - nip05_cache: &mut self.nip05_cache, - i18n: &mut self.i18n, - #[cfg(target_os = "android")] - android: self.android_app.as_ref().unwrap().clone(), + self.notedeck_ref().app_ctx + } + + pub fn notedeck_ref<'a>(&'a mut self) -> NotedeckRef<'a> { + NotedeckRef { + app_ctx: AppContext { + ndb: &mut self.ndb, + img_cache: &mut self.img_cache, + unknown_ids: &mut self.unknown_ids, + pool: &mut self.pool, + note_cache: &mut self.note_cache, + accounts: &mut self.accounts, + global_wallet: &mut self.global_wallet, + path: &self.path, + args: &self.args, + settings: &mut self.settings, + clipboard: &mut self.clipboard, + zaps: &mut self.zaps, + frame_history: &mut self.frame_history, + job_pool: &mut self.job_pool, + media_jobs: &mut self.media_jobs, + nip05_cache: &mut self.nip05_cache, + i18n: &mut self.i18n, + #[cfg(target_os = "android")] + android: self.android_app.as_ref().unwrap().clone(), + }, + internals: NotedeckInternals { + unrecognized_args: &self.unrecognized_args, + }, } } @@ -457,6 +450,33 @@ pub fn install_crypto() { } } +pub struct NotedeckRef<'a> { + pub app_ctx: AppContext<'a>, + pub internals: NotedeckInternals<'a>, +} + +pub struct NotedeckInternals<'a> { + pub unrecognized_args: &'a BTreeSet<String>, +} + +impl<'a> NotedeckInternals<'a> { + /// ensure we recognized all the arguments + pub fn check_args(&self, other_app_args: &BTreeSet<String>) -> Result<(), Error> { + let completely_unrecognized: Vec<String> = self + .unrecognized_args + .intersection(other_app_args) + .cloned() + .collect(); + if !completely_unrecognized.is_empty() { + let err = format!("Unrecognized arguments: {completely_unrecognized:?}"); + tracing::error!("{}", &err); + return Err(Error::Generic(err)); + } + + Ok(()) + } +} + #[profiling::function] pub fn try_process_events_core( app_ctx: &mut AppContext<'_>, diff --git a/crates/notedeck_chrome/src/chrome.rs b/crates/notedeck_chrome/src/chrome.rs @@ -154,12 +154,12 @@ impl Chrome { ) -> Result<Self, Error> { stop_debug_mode(notedeck.options()); - let context = &mut notedeck.app_context(); + let notedeck_ref = &mut notedeck.notedeck_ref(); let dave = Dave::new( cc.wgpu_render_state.as_ref(), - context.ndb.clone(), + notedeck_ref.app_ctx.ndb.clone(), cc.egui_ctx.clone(), - context.path, + notedeck_ref.app_ctx.path, ); #[cfg(feature = "wasm")] let wasm_dir = context @@ -169,8 +169,10 @@ impl Chrome { let mut chrome = Chrome::default(); if !app_args.iter().any(|arg| arg == "--no-columns-app") { - let columns = Damus::new(context, app_args); - notedeck.check_args(columns.unrecognized_args())?; + let columns = Damus::new(&mut notedeck_ref.app_ctx, app_args); + notedeck_ref + .internals + .check_args(columns.unrecognized_args())?; chrome.add_app(NotedeckApp::Columns(Box::new(columns))); }