From 18ea05db0ab294d6d0f0aa738054e6804a1cb1ab Mon Sep 17 00:00:00 2001 From: kernelkind Date: Tue, 1 Apr 2025 21:58:23 -0400 Subject: [PATCH] use `Zaps` Signed-off-by: kernelkind --- crates/notedeck/src/app.rs | 5 +++++ crates/notedeck/src/context.rs | 4 +++- crates/notedeck/src/lib.rs | 2 ++ crates/notedeck/src/zaps/cache.rs | 1 + crates/notedeck/src/zaps/mod.rs | 4 +++- crates/notedeck_columns/src/nav.rs | 1 + crates/notedeck_columns/src/ui/note/contents.rs | 3 ++- crates/notedeck_columns/src/ui/note/post.rs | 1 + 8 files changed, 18 insertions(+), 3 deletions(-) diff --git a/crates/notedeck/src/app.rs b/crates/notedeck/src/app.rs index 402e7fa3..26129155 100644 --- a/crates/notedeck/src/app.rs +++ b/crates/notedeck/src/app.rs @@ -1,5 +1,6 @@ use crate::persist::{AppSizeHandler, ZoomHandler}; use crate::wallet::GlobalWallet; +use crate::zaps::Zaps; use crate::{ AccountStorage, Accounts, AppContext, Args, DataPath, DataPathType, Directory, Images, NoteCache, RelayDebugView, ThemeHandler, UnknownIds, @@ -35,6 +36,7 @@ pub struct Notedeck { app_size: AppSizeHandler, unrecognized_args: BTreeSet, clipboard: Clipboard, + zaps: Zaps, } /// Our chrome, which is basically nothing @@ -205,6 +207,7 @@ impl Notedeck { } let global_wallet = GlobalWallet::new(&path); + let zaps = Zaps::default(); Self { ndb, @@ -222,6 +225,7 @@ impl Notedeck { app_size, unrecognized_args, clipboard: Clipboard::new(None), + zaps, } } @@ -243,6 +247,7 @@ impl Notedeck { args: &self.args, theme: &mut self.theme, clipboard: &mut self.clipboard, + zaps: &mut self.zaps, } } diff --git a/crates/notedeck/src/context.rs b/crates/notedeck/src/context.rs index c2b07642..ab0e90fe 100644 --- a/crates/notedeck/src/context.rs +++ b/crates/notedeck/src/context.rs @@ -1,5 +1,6 @@ use crate::{ - wallet::GlobalWallet, Accounts, Args, DataPath, Images, NoteCache, ThemeHandler, UnknownIds, + wallet::GlobalWallet, zaps::Zaps, Accounts, Args, DataPath, Images, NoteCache, ThemeHandler, + UnknownIds, }; use egui_winit::clipboard::Clipboard; @@ -20,4 +21,5 @@ pub struct AppContext<'a> { pub args: &'a Args, pub theme: &'a mut ThemeHandler, pub clipboard: &'a mut Clipboard, + pub zaps: &'a mut Zaps, } diff --git a/crates/notedeck/src/lib.rs b/crates/notedeck/src/lib.rs index 655047ca..e1034ae8 100644 --- a/crates/notedeck/src/lib.rs +++ b/crates/notedeck/src/lib.rs @@ -61,3 +61,5 @@ pub use wallet::{ // export libs pub use enostr; pub use nostrdb; + +pub use zaps::Zaps; \ No newline at end of file diff --git a/crates/notedeck/src/zaps/cache.rs b/crates/notedeck/src/zaps/cache.rs index 4bdd49b6..75a32c91 100644 --- a/crates/notedeck/src/zaps/cache.rs +++ b/crates/notedeck/src/zaps/cache.rs @@ -14,6 +14,7 @@ use super::{ type ZapId = u32; #[allow(dead_code)] +#[derive(Default)] pub struct Zaps { next_id: ZapId, zap_keys: hashbrown::HashMap>, diff --git a/crates/notedeck/src/zaps/mod.rs b/crates/notedeck/src/zaps/mod.rs index d157b521..3f2b8814 100644 --- a/crates/notedeck/src/zaps/mod.rs +++ b/crates/notedeck/src/zaps/mod.rs @@ -1,3 +1,5 @@ mod cache; mod networking; -mod zap; \ No newline at end of file +mod zap; + +pub use cache::Zaps; diff --git a/crates/notedeck_columns/src/nav.rs b/crates/notedeck_columns/src/nav.rs index 0ca4d1e2..b5ced836 100644 --- a/crates/notedeck_columns/src/nav.rs +++ b/crates/notedeck_columns/src/nav.rs @@ -256,6 +256,7 @@ fn render_nav_body( ndb: ctx.ndb, img_cache: ctx.img_cache, note_cache: ctx.note_cache, + zaps: ctx.zaps, }; match top { Route::Timeline(kind) => render_timeline_route( diff --git a/crates/notedeck_columns/src/ui/note/contents.rs b/crates/notedeck_columns/src/ui/note/contents.rs index db82f6e7..1f650cb4 100644 --- a/crates/notedeck_columns/src/ui/note/contents.rs +++ b/crates/notedeck_columns/src/ui/note/contents.rs @@ -9,7 +9,7 @@ use egui::{Button, Color32, Hyperlink, Image, Response, RichText, Sense, Window} use nostrdb::{BlockType, Mention, Ndb, Note, NoteKey, Transaction}; use tracing::warn; -use notedeck::{supported_mime_hosted_at_url, Images, MediaCacheType, NoteCache}; +use notedeck::{supported_mime_hosted_at_url, Images, MediaCacheType, NoteCache, Zaps}; /// Aggregates dependencies to reduce the number of parameters /// passed to inner UI elements, minimizing prop drilling. @@ -17,6 +17,7 @@ pub struct NoteContext<'d> { pub ndb: &'d Ndb, pub img_cache: &'d mut Images, pub note_cache: &'d mut NoteCache, + pub zaps: &'d mut Zaps, } pub struct NoteContents<'a, 'd> { diff --git a/crates/notedeck_columns/src/ui/note/post.rs b/crates/notedeck_columns/src/ui/note/post.rs index fb5582dd..1ad40354 100644 --- a/crates/notedeck_columns/src/ui/note/post.rs +++ b/crates/notedeck_columns/src/ui/note/post.rs @@ -732,6 +732,7 @@ mod preview { ndb: app.ndb, img_cache: app.img_cache, note_cache: app.note_cache, + zaps: app.zaps, }; PostView::new(