Skip to content

Commit faefbdc

Browse files
committed
Merge zap-notifications
2 parents ecaba2b + 2488027 commit faefbdc

22 files changed

Lines changed: 881 additions & 105 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/notedeck/src/app.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::nip05::Nip05Cache;
44
use crate::persist::{AppSizeHandler, SettingsHandler};
55
use crate::remote_data::RemoteState;
66
use crate::wallet::GlobalWallet;
7-
use crate::zaps::Zaps;
7+
use crate::zaps::{ZapVerifier, Zaps};
88
use crate::NotedeckOptions;
99
use crate::{
1010
frame_history::FrameHistory, AccountStorage, Accounts, AppContext, Args, DataPath,
@@ -108,6 +108,7 @@ pub struct Notedeck {
108108
unrecognized_args: BTreeSet<String>,
109109
clipboard: Clipboard,
110110
zaps: Zaps,
111+
zap_verifier: ZapVerifier,
111112
frame_history: FrameHistory,
112113
job_pool: JobPool,
113114
media_jobs: MediaJobs,
@@ -186,6 +187,7 @@ impl Notedeck {
186187
self.remote.process_events(ctx, &self.ndb);
187188
}
188189
self.nip05_cache.poll();
190+
self.zap_verifier.poll(&self.ndb, self.zaps.pay_cache());
189191
let Some(app) = &self.app else {
190192
self.remote
191193
.request_repaint_for_next_full_history_deadline(ctx);
@@ -388,6 +390,7 @@ impl Notedeck {
388390
frame_history: FrameHistory::default(),
389391
clipboard: Clipboard::new(None),
390392
zaps,
393+
zap_verifier: ZapVerifier::new(),
391394
job_pool,
392395
media_jobs: media_job_cache,
393396
nip05_cache: Nip05Cache::new(),
@@ -439,6 +442,7 @@ impl Notedeck {
439442
settings: &mut self.settings,
440443
clipboard: &mut self.clipboard,
441444
zaps: &mut self.zaps,
445+
zap_verifier: &mut self.zap_verifier,
442446
frame_history: &mut self.frame_history,
443447
job_pool: &mut self.job_pool,
444448
media_jobs: &mut self.media_jobs,

crates/notedeck/src/args.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ impl Args {
139139
res.relays.push(relay.clone());
140140
} else if arg == "--no-keystore" {
141141
res.options.set(NotedeckOptions::UseKeystore, false);
142+
} else if arg == "--all-apps-active" {
143+
res.options.set(NotedeckOptions::AllAppsActive, true);
142144
} else if arg == "--title" {
143145
i += 1;
144146
let title = if let Some(next_arg) = args.get(i) {

crates/notedeck/src/context.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{
22
account::accounts::Accounts, frame_history::FrameHistory, i18n::Localization,
3-
nip05::Nip05Cache, sound::SoundManager, wallet::GlobalWallet, zaps::Zaps, Args, DataPath,
4-
Images, JobPool, MediaJobs, NoteCache, RemoteApi, SettingsHandler, UnknownIds,
3+
nip05::Nip05Cache, sound::SoundManager, wallet::GlobalWallet, zaps::ZapVerifier, zaps::Zaps,
4+
Args, DataPath, Images, JobPool, MediaJobs, NoteCache, RemoteApi, SettingsHandler, UnknownIds,
55
};
66
use egui_winit::clipboard::Clipboard;
77
use enostr::Pubkey;
@@ -27,6 +27,7 @@ pub struct AppContext<'a> {
2727
pub settings: &'a mut SettingsHandler,
2828
pub clipboard: &'a mut Clipboard,
2929
pub zaps: &'a mut Zaps,
30+
pub zap_verifier: &'a mut ZapVerifier,
3031
pub frame_history: &'a mut FrameHistory,
3132
pub job_pool: &'a mut JobPool,
3233
pub media_jobs: &'a mut MediaJobs,

crates/notedeck/src/options.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ bitflags! {
2222

2323
/// Show the native window titlebar?
2424
const ShowTitle = 1 << 7;
25+
26+
/// Update all apps every frame, even if they haven't been opened yet
27+
const AllAppsActive = 1 << 8;
2528
}
2629
}
2730

crates/notedeck/src/zaps/cache.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,10 @@ impl Zaps {
229229
});
230230
}
231231

232+
pub fn pay_cache(&mut self) -> &mut PayCache {
233+
&mut self.pay_cache
234+
}
235+
232236
pub fn send_error(&mut self, sender_pubkey: &[u8; 32], target: ZapTarget, error: ZappingError) {
233237
let id = self.get_next_id();
234238
let key = ZapKey {

crates/notedeck/src/zaps/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
mod cache;
22
mod default_zap;
33
mod networking;
4+
mod verify;
45
mod zap;
56

67
pub use cache::{
78
AnyZapState, NoteZapTarget, NoteZapTargetOwned, ZapTarget, ZapTargetOwned, ZappingError, Zaps,
89
};
910

11+
pub use verify::ZapVerifier;
12+
1013
pub use default_zap::{
1114
get_current_default_msats, DefaultZapError, DefaultZapMsats, PendingDefaultZapState,
1215
UserZapMsats,

crates/notedeck/src/zaps/networking.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub struct FetchedInvoiceResponse {
2222

2323
pub type FetchingInvoice = Promise<Result<FetchedInvoiceResponse, JoinError>>;
2424

25-
async fn fetch_pay_req_async(url: &Url) -> Result<LNUrlPayResponseRaw, ZapError> {
25+
pub(crate) async fn fetch_pay_req_async(url: &Url) -> Result<LNUrlPayResponseRaw, ZapError> {
2626
let (sender, promise) = Promise::new();
2727

2828
let on_done = move |response: Result<ehttp::Response, String>| {
@@ -232,7 +232,7 @@ pub fn fetch_invoice_promise(
232232
}
233233
}
234234

235-
fn convert_lnurl_to_endpoint_url(lnurl: &str) -> Result<Url, ZapError> {
235+
pub(crate) fn convert_lnurl_to_endpoint_url(lnurl: &str) -> Result<Url, ZapError> {
236236
let (_, data) = bech32::decode(lnurl).map_err(|e| ZapError::Bech(e.to_string()))?;
237237

238238
let url_str =
@@ -345,7 +345,7 @@ async fn fetch_ln_invoice(req: &Url) -> Result<LNInvoice, ZapError> {
345345
tokio::task::block_in_place(|| promise.block_and_take())
346346
}
347347

348-
fn generate_endpoint_url(lud16: &str) -> Result<Url, ZapError> {
348+
pub(crate) fn generate_endpoint_url(lud16: &str) -> Result<Url, ZapError> {
349349
let (user, domain, use_http) = {
350350
let mut split = lud16.split('@');
351351
let user = split

0 commit comments

Comments
 (0)