feat: immersive onboarding (#189)

* feat: change the default onboarding column

* feat: add newsfeed onboarding

* feat: add topic onboarding

* feat: add group onboarding

* chore: polish and format

* feat: rename foryou to topic

* fix: array
This commit is contained in:
雨宮蓮
2024-05-22 10:44:19 +07:00
committed by GitHub
parent 9b5867f80c
commit 1f38eba2cc
35 changed files with 2291 additions and 2358 deletions

View File

@@ -97,6 +97,7 @@ pub async fn get_events_by(
#[tauri::command]
pub async fn get_local_events(
pubkeys: Vec<String>,
limit: usize,
until: Option<&str>,
state: State<'_, Nostr>,
@@ -106,26 +107,21 @@ pub async fn get_local_events(
Some(until) => Timestamp::from_str(until).unwrap(),
None => Timestamp::now(),
};
let authors: Vec<PublicKey> = pubkeys
.into_iter()
.map(|p| PublicKey::from_hex(p).unwrap())
.collect();
let filter = Filter::new()
.kinds(vec![Kind::TextNote, Kind::Repost])
.limit(limit)
.authors(authors)
.until(as_of);
match client
.get_contact_list_public_keys(Some(Duration::from_secs(10)))
.get_events_of(vec![filter], Some(Duration::from_secs(8)))
.await
{
Ok(contacts) => {
let filter = Filter::new()
.kinds(vec![Kind::TextNote, Kind::Repost])
.limit(limit)
.authors(contacts)
.until(as_of);
match client
.get_events_of(vec![filter], Some(Duration::from_secs(8)))
.await
{
Ok(events) => Ok(events),
Err(err) => Err(err.to_string()),
}
}
Ok(events) => Ok(events),
Err(err) => Err(err.to_string()),
}
}

View File

@@ -182,19 +182,38 @@ pub async fn get_profile(id: &str, state: State<'_, Nostr>) -> Result<Metadata,
}
}
#[tauri::command]
pub async fn set_contact_list(pubkeys: Vec<&str>, state: State<'_, Nostr>) -> Result<bool, String> {
let client = &state.client;
let contact_list: Vec<Contact> = pubkeys
.into_iter()
.map(|p| Contact::new(PublicKey::from_hex(p).unwrap(), None, Some("")))
.collect();
match client.set_contact_list(contact_list).await {
Ok(_) => Ok(true),
Err(err) => Err(err.to_string()),
}
}
#[tauri::command]
pub async fn get_contact_list(state: State<'_, Nostr>) -> Result<Vec<String>, String> {
let client = &state.client;
if let Ok(contact_list) = client.get_contact_list(Some(Duration::from_secs(10))).await {
let list = contact_list
.into_iter()
.map(|f| f.public_key.to_hex())
.collect();
match client.get_contact_list(Some(Duration::from_secs(10))).await {
Ok(contact_list) => {
if !contact_list.is_empty() {
let list = contact_list
.into_iter()
.map(|f| f.public_key.to_hex())
.collect();
Ok(list)
} else {
Err("Contact list not found".into())
Ok(list)
} else {
Err("Empty.".into())
}
}
Err(err) => Err(err.to_string()),
}
}