chore: fix the issue when new user cannot see their messages

This commit is contained in:
2025-02-25 18:21:10 +07:00
parent 111ab3b082
commit 29ec6da872
2 changed files with 63 additions and 36 deletions

View File

@@ -1,3 +1,4 @@
use common::constants::NEW_MESSAGE_SUB_ID;
use gpui::{
div, prelude::FluentBuilder, px, uniform_list, AppContext, Context, Entity, FocusHandle,
InteractiveElement, IntoElement, ParentElement, Render, Styled, Task, TextAlign, Window,
@@ -84,13 +85,39 @@ impl Relays {
}
let tags: Vec<Tag> = relays
.into_iter()
.iter()
.map(|relay| Tag::custom(TagKind::Relay, vec![relay.to_string()]))
.collect();
let builder = EventBuilder::new(Kind::InboxRelays, "").tags(tags);
let output = client.send_event_builder(builder).await?;
// Connect to messaging relays
for relay in relays.into_iter() {
_ = client.add_relay(&relay).await;
_ = client.connect_relay(&relay).await;
}
let sub_id = SubscriptionId::new(NEW_MESSAGE_SUB_ID);
// Close old subscription
client.unsubscribe(&sub_id).await;
// Subscribe to new messages
if let Err(e) = client
.subscribe_with_id(
sub_id,
Filter::new()
.kind(Kind::GiftWrap)
.pubkey(public_key)
.limit(0),
None,
)
.await
{
log::error!("Failed to subscribe to new messages: {}", e);
}
Ok(output.val)
});