feat: add user screen

This commit is contained in:
2024-02-27 13:42:59 +07:00
parent 98ef1927f2
commit 2403231ac4
9 changed files with 173 additions and 31 deletions

View File

@@ -107,6 +107,7 @@ fn main() {
nostr::metadata::set_settings,
nostr::metadata::get_settings,
nostr::event::get_event,
nostr::event::get_events_from,
nostr::event::get_local_events,
nostr::event::get_global_events,
nostr::event::get_event_thread,

View File

@@ -38,6 +38,39 @@ pub async fn get_event(id: &str, state: State<'_, Nostr>) -> Result<String, Stri
}
}
#[tauri::command]
pub async fn get_events_from(
id: &str,
limit: usize,
until: Option<&str>,
state: State<'_, Nostr>,
) -> Result<Vec<Event>, String> {
let client = &state.client;
let f_until = match until {
Some(until) => Timestamp::from_str(until).unwrap(),
None => Timestamp::now(),
};
if let Ok(author) = PublicKey::from_str(id) {
let filter = Filter::new()
.kinds(vec![Kind::TextNote, Kind::Repost])
.authors(vec![author])
.limit(limit)
.until(f_until);
if let Ok(events) = client
.get_events_of(vec![filter], Some(Duration::from_secs(10)))
.await
{
Ok(events)
} else {
Err("Get text event failed".into())
}
} else {
Err("Parse author failed".into())
}
}
#[tauri::command]
pub async fn get_local_events(
limit: usize,