From b5b2ea9b71264a81470e4c7b4dda48f91c547d24 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Tue, 20 Aug 2024 14:16:51 +0300 Subject: [PATCH] fix(main): client communication ordering --- src/main.rs | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/main.rs b/src/main.rs index 590b777..e6a1dae 100644 --- a/src/main.rs +++ b/src/main.rs @@ -180,14 +180,14 @@ async fn main() { }, } + let mut notifications = client.notifications(); + client.connect().await; + let sub1 = client.subscribe(vec![ Filter::new().kinds(KINDS.into_iter().map(|k| Kind::from(k))) ], None).await; info!("Subscribed to tasks with {:?}", sub1); - let mut notifications = client.notifications(); - client.connect().await; - let sub2 = client.subscribe(vec![ Filter::new().kinds(PROP_KINDS.into_iter().map(|k| Kind::from(k))) ], None).await; @@ -201,20 +201,13 @@ async fn main() { let sender = tokio::spawn(async move { let mut queue: Option<(Url, Vec)> = None; - loop { - if let Ok(user) = var("USER") { - let metadata = Metadata::new() - .name(user); - // .display_name("My Username") - // .about("Description") - // .picture(Url::parse("https://example.com/avatar.png")?) - // .banner(Url::parse("https://example.com/banner.png")?) - // .nip05("username@example.com") - // .lud16("yuki@getalby.com") - // .custom_field("custom_field", "my value"); - or_print(client.set_metadata(&metadata).await); - } + if let Ok(user) = var("USER") { + let metadata = Metadata::new() + .name(user); + or_print(client.set_metadata(&metadata).await); + } + loop { let result_received = rx.recv_timeout(Duration::from_secs(INACTVITY_DELAY)); match result_received { Ok(MostrMessage::NewRelay(url)) => {