feat: re-enable gossip and optimize
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
wss://relay.damus.io,
|
wss://relay.damus.io,
|
||||||
wss://relay.primal.net,
|
wss://relay.primal.net,
|
||||||
wss://relay.nostr.band,
|
|
||||||
wss://nostr.fmt.wiz.biz,
|
wss://nostr.fmt.wiz.biz,
|
||||||
|
wss://directory.yabu.me,
|
||||||
|
wss://purplepag.es,
|
||||||
|
|||||||
@@ -77,13 +77,20 @@ pub async fn get_replies(id: String, state: State<'_, Nostr>) -> Result<Vec<Rich
|
|||||||
.kinds(vec![Kind::TextNote, Kind::Custom(1111)])
|
.kinds(vec![Kind::TextNote, Kind::Custom(1111)])
|
||||||
.event(event_id);
|
.event(event_id);
|
||||||
|
|
||||||
match client
|
let mut events = Events::new(&[filter.clone()]);
|
||||||
.fetch_events(vec![filter], Some(Duration::from_secs(5)))
|
|
||||||
|
let mut rx = client
|
||||||
|
.stream_events(vec![filter], Some(Duration::from_secs(3)))
|
||||||
.await
|
.await
|
||||||
{
|
.map_err(|e| e.to_string())?;
|
||||||
Ok(events) => Ok(process_event(client, events, true).await),
|
|
||||||
Err(err) => Err(err.to_string()),
|
while let Some(event) = rx.next().await {
|
||||||
|
events.insert(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let alt_events = process_event(client, events, true).await;
|
||||||
|
|
||||||
|
Ok(alt_events)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@@ -101,13 +108,20 @@ pub async fn get_all_events_by_author(
|
|||||||
.author(author)
|
.author(author)
|
||||||
.limit(limit as usize);
|
.limit(limit as usize);
|
||||||
|
|
||||||
match client
|
let mut events = Events::new(&[filter.clone()]);
|
||||||
.fetch_events(vec![filter], Some(Duration::from_secs(3)))
|
|
||||||
|
let mut rx = client
|
||||||
|
.stream_events(vec![filter], Some(Duration::from_secs(3)))
|
||||||
.await
|
.await
|
||||||
{
|
.map_err(|e| e.to_string())?;
|
||||||
Ok(events) => Ok(process_event(client, events, false).await),
|
|
||||||
Err(err) => Err(err.to_string()),
|
while let Some(event) = rx.next().await {
|
||||||
|
events.insert(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let alt_events = process_event(client, events, false).await;
|
||||||
|
|
||||||
|
Ok(alt_events)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@@ -120,28 +134,35 @@ pub async fn get_all_events_by_authors(
|
|||||||
let client = &state.client;
|
let client = &state.client;
|
||||||
|
|
||||||
let as_of = match until {
|
let as_of = match until {
|
||||||
Some(until) => Timestamp::from_str(&until).map_err(|err| err.to_string())?,
|
Some(until) => Timestamp::from_str(&until).unwrap_or(Timestamp::now()),
|
||||||
None => Timestamp::now(),
|
None => Timestamp::now(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let authors: Vec<PublicKey> = public_keys
|
let authors: Vec<PublicKey> = public_keys
|
||||||
.iter()
|
.iter()
|
||||||
.map(|pk| PublicKey::from_str(pk).map_err(|err| err.to_string()))
|
.filter_map(|pk| PublicKey::from_str(pk).ok())
|
||||||
.collect::<Result<Vec<_>, _>>()?;
|
.collect();
|
||||||
|
|
||||||
let filter = Filter::new()
|
let filter = Filter::new()
|
||||||
|
.authors(authors)
|
||||||
.kinds(vec![Kind::TextNote, Kind::Repost])
|
.kinds(vec![Kind::TextNote, Kind::Repost])
|
||||||
.limit(FETCH_LIMIT)
|
.limit(FETCH_LIMIT)
|
||||||
.until(as_of)
|
.until(as_of);
|
||||||
.authors(authors);
|
|
||||||
|
|
||||||
match client
|
let mut events = Events::new(&[filter.clone()]);
|
||||||
.fetch_events(vec![filter], Some(Duration::from_secs(3)))
|
|
||||||
|
let mut rx = client
|
||||||
|
.stream_events(vec![filter], Some(Duration::from_secs(3)))
|
||||||
.await
|
.await
|
||||||
{
|
.map_err(|e| e.to_string())?;
|
||||||
Ok(events) => Ok(process_event(client, events, false).await),
|
|
||||||
Err(err) => Err(err.to_string()),
|
while let Some(event) = rx.next().await {
|
||||||
|
events.insert(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let alt_events = process_event(client, events, false).await;
|
||||||
|
|
||||||
|
Ok(alt_events)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@@ -164,13 +185,20 @@ pub async fn get_all_events_by_hashtags(
|
|||||||
.until(as_of)
|
.until(as_of)
|
||||||
.hashtags(hashtags);
|
.hashtags(hashtags);
|
||||||
|
|
||||||
match client
|
let mut events = Events::new(&[filter.clone()]);
|
||||||
.fetch_events(vec![filter], Some(Duration::from_secs(3)))
|
|
||||||
|
let mut rx = client
|
||||||
|
.stream_events(vec![filter], Some(Duration::from_secs(3)))
|
||||||
.await
|
.await
|
||||||
{
|
.map_err(|e| e.to_string())?;
|
||||||
Ok(events) => Ok(process_event(client, events, false).await),
|
|
||||||
Err(err) => Err(err.to_string()),
|
while let Some(event) = rx.next().await {
|
||||||
|
events.insert(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let alt_events = process_event(client, events, false).await;
|
||||||
|
|
||||||
|
Ok(alt_events)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
|
|||||||
@@ -5,10 +5,7 @@ use specta::Type;
|
|||||||
use std::{str::FromStr, time::Duration};
|
use std::{str::FromStr, time::Duration};
|
||||||
use tauri::{Emitter, Manager, State};
|
use tauri::{Emitter, Manager, State};
|
||||||
|
|
||||||
use crate::{
|
use crate::{common::process_event, Nostr, RichEvent};
|
||||||
common::{get_latest_event, process_event},
|
|
||||||
Nostr, RichEvent,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(Clone, Serialize, Deserialize, Type)]
|
#[derive(Clone, Serialize, Deserialize, Type)]
|
||||||
pub struct Mention {
|
pub struct Mention {
|
||||||
@@ -71,35 +68,15 @@ pub async fn get_contact_list(id: String, state: State<'_, Nostr>) -> Result<Vec
|
|||||||
let client = &state.client;
|
let client = &state.client;
|
||||||
let public_key = PublicKey::parse(&id).map_err(|e| e.to_string())?;
|
let public_key = PublicKey::parse(&id).map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
let filter = Filter::new()
|
let contact_list = client
|
||||||
.author(public_key)
|
.database()
|
||||||
.kind(Kind::ContactList)
|
.contacts_public_keys(public_key)
|
||||||
.limit(1);
|
|
||||||
|
|
||||||
let mut contact_list: Vec<String> = Vec::new();
|
|
||||||
|
|
||||||
match client
|
|
||||||
.fetch_events(vec![filter], Some(Duration::from_secs(3)))
|
|
||||||
.await
|
.await
|
||||||
{
|
.map_err(|e| e.to_string())?;
|
||||||
Ok(events) => {
|
|
||||||
if let Some(event) = events.into_iter().next() {
|
|
||||||
for tag in event.tags.into_iter() {
|
|
||||||
if let Some(TagStandard::PublicKey {
|
|
||||||
public_key,
|
|
||||||
uppercase: false,
|
|
||||||
..
|
|
||||||
}) = tag.to_standardized()
|
|
||||||
{
|
|
||||||
contact_list.push(public_key.to_hex())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(contact_list)
|
let pubkeys: Vec<String> = contact_list.into_iter().map(|pk| pk.to_hex()).collect();
|
||||||
}
|
|
||||||
Err(e) => Err(e.to_string()),
|
Ok(pubkeys)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@@ -120,21 +97,9 @@ pub async fn is_contact(id: String, state: State<'_, Nostr>) -> Result<bool, Str
|
|||||||
let client = &state.client;
|
let client = &state.client;
|
||||||
let public_key = PublicKey::parse(&id).map_err(|e| e.to_string())?;
|
let public_key = PublicKey::parse(&id).map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
let filter = Filter::new()
|
match client.database().contacts_public_keys(public_key).await {
|
||||||
.author(public_key)
|
Ok(public_keys) => Ok(public_keys.iter().any(|i| i == &public_key)),
|
||||||
.kind(Kind::ContactList)
|
Err(_) => Ok(false),
|
||||||
.limit(1);
|
|
||||||
|
|
||||||
match client.database().query(vec![filter]).await {
|
|
||||||
Ok(events) => {
|
|
||||||
if let Some(event) = events.into_iter().next() {
|
|
||||||
let pubkeys = event.tags.public_keys().collect::<Vec<_>>();
|
|
||||||
Ok(pubkeys.iter().any(|&i| i == &public_key))
|
|
||||||
} else {
|
|
||||||
Ok(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(e) => Err(e.to_string()),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,16 +209,15 @@ pub async fn set_group(
|
|||||||
pub async fn get_group(id: String, state: State<'_, Nostr>) -> Result<String, String> {
|
pub async fn get_group(id: String, state: State<'_, Nostr>) -> Result<String, String> {
|
||||||
let client = &state.client;
|
let client = &state.client;
|
||||||
let event_id = EventId::from_str(&id).map_err(|e| e.to_string())?;
|
let event_id = EventId::from_str(&id).map_err(|e| e.to_string())?;
|
||||||
let filter = Filter::new().kind(Kind::FollowSet).id(event_id);
|
|
||||||
|
|
||||||
match client
|
match client.database().event_by_id(&event_id).await {
|
||||||
.fetch_events(vec![filter], Some(Duration::from_secs(3)))
|
Ok(event) => {
|
||||||
.await
|
if let Some(ev) = event {
|
||||||
{
|
Ok(ev.as_json())
|
||||||
Ok(events) => match get_latest_event(&events) {
|
} else {
|
||||||
Some(ev) => Ok(ev.as_json()),
|
Err("Event not found".into())
|
||||||
None => Err("Not found.".to_string()),
|
}
|
||||||
},
|
}
|
||||||
Err(e) => Err(e.to_string()),
|
Err(e) => Err(e.to_string()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -273,11 +237,17 @@ pub async fn get_all_newsfeeds(
|
|||||||
.author(public_key)
|
.author(public_key)
|
||||||
.limit(1);
|
.limit(1);
|
||||||
|
|
||||||
let remote_events = client
|
let mut remote_events = Events::new(&[groups.clone()]);
|
||||||
.fetch_events(vec![groups], Some(Duration::from_secs(3)))
|
|
||||||
|
let mut rx = client
|
||||||
|
.stream_events(vec![groups], Some(Duration::from_secs(3)))
|
||||||
.await
|
.await
|
||||||
.map_err(|e| e.to_string())?;
|
.map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
|
while let Some(event) = rx.next().await {
|
||||||
|
remote_events.insert(event);
|
||||||
|
}
|
||||||
|
|
||||||
let contact_events = client
|
let contact_events = client
|
||||||
.fetch_events(vec![contacts], Some(Duration::from_secs(3)))
|
.fetch_events(vec![contacts], Some(Duration::from_secs(3)))
|
||||||
.await
|
.await
|
||||||
@@ -349,18 +319,15 @@ pub async fn set_interest(
|
|||||||
pub async fn get_interest(id: String, state: State<'_, Nostr>) -> Result<String, String> {
|
pub async fn get_interest(id: String, state: State<'_, Nostr>) -> Result<String, String> {
|
||||||
let client = &state.client;
|
let client = &state.client;
|
||||||
let event_id = EventId::from_str(&id).map_err(|e| e.to_string())?;
|
let event_id = EventId::from_str(&id).map_err(|e| e.to_string())?;
|
||||||
let filter = Filter::new()
|
|
||||||
.kinds(vec![Kind::Interests, Kind::InterestSet])
|
|
||||||
.id(event_id);
|
|
||||||
|
|
||||||
match client
|
match client.database().event_by_id(&event_id).await {
|
||||||
.fetch_events(vec![filter], Some(Duration::from_secs(3)))
|
Ok(event) => {
|
||||||
.await
|
if let Some(ev) = event {
|
||||||
{
|
Ok(ev.as_json())
|
||||||
Ok(events) => match get_latest_event(&events) {
|
} else {
|
||||||
Some(ev) => Ok(ev.as_json()),
|
Err("Event not found".into())
|
||||||
None => Err("Not found.".to_string()),
|
}
|
||||||
},
|
}
|
||||||
Err(e) => Err(e.to_string()),
|
Err(e) => Err(e.to_string()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -373,17 +340,25 @@ pub async fn get_all_interests(
|
|||||||
) -> Result<Vec<RichEvent>, String> {
|
) -> Result<Vec<RichEvent>, String> {
|
||||||
let client = &state.client;
|
let client = &state.client;
|
||||||
let public_key = PublicKey::parse(&id).map_err(|e| e.to_string())?;
|
let public_key = PublicKey::parse(&id).map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
let filter = Filter::new()
|
let filter = Filter::new()
|
||||||
.kinds(vec![Kind::InterestSet, Kind::Interests])
|
.kinds(vec![Kind::InterestSet, Kind::Interests])
|
||||||
.author(public_key);
|
.author(public_key);
|
||||||
|
|
||||||
match client
|
let mut events = Events::new(&[filter.clone()]);
|
||||||
.fetch_events(vec![filter], Some(Duration::from_secs(3)))
|
|
||||||
|
let mut rx = client
|
||||||
|
.stream_events(vec![filter], Some(Duration::from_secs(3)))
|
||||||
.await
|
.await
|
||||||
{
|
.map_err(|e| e.to_string())?;
|
||||||
Ok(events) => Ok(process_event(client, events, false).await),
|
|
||||||
Err(e) => Err(e.to_string()),
|
while let Some(event) = rx.next().await {
|
||||||
|
events.insert(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let alt_events = process_event(client, events, false).await;
|
||||||
|
|
||||||
|
Ok(alt_events)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@@ -570,13 +545,20 @@ pub async fn get_notifications(id: String, state: State<'_, Nostr>) -> Result<Ve
|
|||||||
])
|
])
|
||||||
.limit(500);
|
.limit(500);
|
||||||
|
|
||||||
match client
|
let mut events = Events::new(&[filter.clone()]);
|
||||||
.fetch_events(vec![filter], Some(Duration::from_secs(5)))
|
|
||||||
|
let mut rx = client
|
||||||
|
.stream_events(vec![filter], Some(Duration::from_secs(3)))
|
||||||
.await
|
.await
|
||||||
{
|
.map_err(|e| e.to_string())?;
|
||||||
Ok(events) => Ok(events.into_iter().map(|ev| ev.as_json()).collect()),
|
|
||||||
Err(err) => Err(err.to_string()),
|
while let Some(event) = rx.next().await {
|
||||||
|
events.insert(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let alt_events = events.into_iter().map(|ev| ev.as_json()).collect();
|
||||||
|
|
||||||
|
Ok(alt_events)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
|
|||||||
@@ -82,17 +82,19 @@ pub async fn create_column(
|
|||||||
let subscription_id =
|
let subscription_id =
|
||||||
SubscriptionId::new(webview.label());
|
SubscriptionId::new(webview.label());
|
||||||
|
|
||||||
let filter =
|
let filter = Filter::new()
|
||||||
Filter::new().authors(contact_list).kinds(vec![
|
.authors(contact_list)
|
||||||
|
.kinds(vec![
|
||||||
Kind::TextNote,
|
Kind::TextNote,
|
||||||
Kind::Repost,
|
Kind::Repost,
|
||||||
Kind::EventDeletion,
|
Kind::EventDeletion,
|
||||||
]);
|
])
|
||||||
|
.since(Timestamp::now());
|
||||||
|
|
||||||
if let Err(e) = client
|
if let Err(e) = client
|
||||||
.subscribe_with_id(
|
.subscribe_with_id(
|
||||||
subscription_id,
|
subscription_id,
|
||||||
vec![filter.clone().since(Timestamp::now())],
|
vec![filter],
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
@@ -111,7 +113,8 @@ pub async fn create_column(
|
|||||||
|
|
||||||
let filter = Filter::new()
|
let filter = Filter::new()
|
||||||
.event(event_id)
|
.event(event_id)
|
||||||
.kinds(vec![Kind::TextNote, Kind::Custom(1111)]);
|
.kinds(vec![Kind::TextNote, Kind::Custom(1111)])
|
||||||
|
.since(Timestamp::now());
|
||||||
|
|
||||||
if let Err(e) = client
|
if let Err(e) = client
|
||||||
.subscribe_with_id(
|
.subscribe_with_id(
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ fn main() {
|
|||||||
let handle = app.handle();
|
let handle = app.handle();
|
||||||
let handle_clone = handle.clone();
|
let handle_clone = handle.clone();
|
||||||
let handle_clone_child = handle_clone.clone();
|
let handle_clone_child = handle_clone.clone();
|
||||||
|
let handle_clone_event = handle_clone_child.clone();
|
||||||
let main_window = app.get_webview_window("main").unwrap();
|
let main_window = app.get_webview_window("main").unwrap();
|
||||||
|
|
||||||
let config_dir = handle
|
let config_dir = handle
|
||||||
@@ -175,12 +176,9 @@ fn main() {
|
|||||||
|
|
||||||
// Config
|
// Config
|
||||||
let opts = Options::new()
|
let opts = Options::new()
|
||||||
.gossip(false)
|
.gossip(true)
|
||||||
.max_avg_latency(Duration::from_millis(300))
|
.max_avg_latency(Duration::from_millis(300))
|
||||||
.automatic_authentication(true)
|
.automatic_authentication(true)
|
||||||
.connection_timeout(Some(Duration::from_secs(5)))
|
|
||||||
.send_timeout(Some(Duration::from_secs(10)))
|
|
||||||
.wait_for_send(false)
|
|
||||||
.timeout(Duration::from_secs(5));
|
.timeout(Duration::from_secs(5));
|
||||||
|
|
||||||
// Setup nostr client
|
// Setup nostr client
|
||||||
@@ -217,8 +215,6 @@ fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = client.add_discovery_relay("wss://purplepag.es/").await;
|
|
||||||
let _ = client.add_discovery_relay("wss://directory.yabu.me/").await;
|
|
||||||
let _ = client.add_discovery_relay("wss://user.kindpag.es/").await;
|
let _ = client.add_discovery_relay("wss://user.kindpag.es/").await;
|
||||||
|
|
||||||
// Connect
|
// Connect
|
||||||
@@ -227,6 +223,62 @@ fn main() {
|
|||||||
client
|
client
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Trigger some actions for window events
|
||||||
|
main_window.on_window_event(move |event| match event {
|
||||||
|
tauri::WindowEvent::Focused(focused) => {
|
||||||
|
if !focused {
|
||||||
|
let handle = handle_clone_event.clone();
|
||||||
|
|
||||||
|
tauri::async_runtime::spawn(async move {
|
||||||
|
let state = handle.state::<Nostr>();
|
||||||
|
let client = &state.client;
|
||||||
|
|
||||||
|
let filter = Filter::new().kinds(vec![
|
||||||
|
Kind::TextNote,
|
||||||
|
Kind::Repost,
|
||||||
|
Kind::ContactList,
|
||||||
|
Kind::FollowSet,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Get all public keys in database
|
||||||
|
if let Ok(events) = client.database().query(vec![filter]).await {
|
||||||
|
let public_keys: HashSet<PublicKey> = events
|
||||||
|
.iter()
|
||||||
|
.flat_map(|ev| ev.tags.public_keys().copied())
|
||||||
|
.collect();
|
||||||
|
let pk_vec: Vec<PublicKey> = public_keys.into_iter().collect();
|
||||||
|
|
||||||
|
for chunk in pk_vec.chunks(500) {
|
||||||
|
if chunk.is_empty() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let authors = chunk.to_owned();
|
||||||
|
let filter = Filter::new()
|
||||||
|
.authors(authors)
|
||||||
|
.kinds(vec![
|
||||||
|
Kind::Metadata,
|
||||||
|
Kind::TextNote,
|
||||||
|
Kind::FollowSet,
|
||||||
|
Kind::Interests,
|
||||||
|
Kind::InterestSet,
|
||||||
|
])
|
||||||
|
.limit(2000);
|
||||||
|
|
||||||
|
let opts = SyncOptions::default();
|
||||||
|
|
||||||
|
if let Err(e) = client.sync(filter, &opts).await {
|
||||||
|
println!("Sync error: {}", e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tauri::WindowEvent::Moved(_size) => {}
|
||||||
|
_ => {}
|
||||||
|
});
|
||||||
|
|
||||||
// Create global state
|
// Create global state
|
||||||
app.manage(Nostr {
|
app.manage(Nostr {
|
||||||
client,
|
client,
|
||||||
@@ -276,24 +328,27 @@ fn main() {
|
|||||||
let accounts = get_all_accounts();
|
let accounts = get_all_accounts();
|
||||||
|
|
||||||
if !accounts.is_empty() {
|
if !accounts.is_empty() {
|
||||||
|
let subscription_id = SubscriptionId::new(NOTIFICATION_SUB_ID);
|
||||||
|
|
||||||
let public_keys: Vec<PublicKey> = accounts
|
let public_keys: Vec<PublicKey> = accounts
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|acc| {
|
.filter_map(|acc| PublicKey::from_str(acc).ok())
|
||||||
if let Ok(pk) = PublicKey::from_str(acc) {
|
|
||||||
Some(pk)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
let filter = Filter::new()
|
||||||
|
.pubkeys(public_keys)
|
||||||
|
.kinds(vec![
|
||||||
|
Kind::TextNote,
|
||||||
|
Kind::Repost,
|
||||||
|
Kind::Reaction,
|
||||||
|
Kind::ZapReceipt,
|
||||||
|
Kind::Custom(1111),
|
||||||
|
])
|
||||||
|
.since(Timestamp::now());
|
||||||
|
|
||||||
// Subscribe for new notification
|
// Subscribe for new notification
|
||||||
if let Err(e) = client
|
if let Err(e) = client
|
||||||
.subscribe_with_id(
|
.subscribe_with_id(subscription_id, vec![filter], None)
|
||||||
SubscriptionId::new(NOTIFICATION_SUB_ID),
|
|
||||||
vec![Filter::new().pubkeys(public_keys).since(Timestamp::now())],
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
println!("Error: {}", e)
|
println!("Error: {}", e)
|
||||||
|
|||||||
@@ -88,13 +88,11 @@ function Newsfeeds() {
|
|||||||
{item.tags
|
{item.tags
|
||||||
.filter((tag) => tag[0] === "p")
|
.filter((tag) => tag[0] === "p")
|
||||||
.map((tag) => (
|
.map((tag) => (
|
||||||
<div key={tag[1]}>
|
<User.Provider key={tag[1]} pubkey={tag[1]}>
|
||||||
<User.Provider pubkey={tag[1]}>
|
<User.Root>
|
||||||
<User.Root>
|
<User.Avatar className="size-8 rounded-full" />
|
||||||
<User.Avatar className="size-8 rounded-full" />
|
</User.Root>
|
||||||
</User.Root>
|
</User.Provider>
|
||||||
</User.Provider>
|
|
||||||
</div>
|
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</ScrollArea.Viewport>
|
</ScrollArea.Viewport>
|
||||||
|
|||||||
Reference in New Issue
Block a user