feat: update ui and add compose dialog

This commit is contained in:
reya
2024-07-29 14:49:13 +07:00
parent a65d5d0c1a
commit 6ceac40394
16 changed files with 913 additions and 345 deletions

View File

@@ -141,6 +141,15 @@ pub async fn connect_account(uri: &str, state: State<'_, Nostr>) -> Result<Strin
}
}
#[tauri::command]
#[specta::specta]
pub async fn get_contact_list(state: State<'_, Nostr>) -> Result<Vec<String>, ()> {
let contact_list = state.contact_list.lock().await;
let list = contact_list.clone().into_iter().map(|c| c.public_key.to_hex()).collect::<Vec<_>>();
Ok(list)
}
#[tauri::command]
#[specta::specta]
pub async fn login(
@@ -185,6 +194,11 @@ pub async fn login(
}
}
if let Ok(contacts) = client.get_contact_list(Some(Duration::from_secs(10))).await {
let mut contact_list = state.contact_list.lock().await;
*contact_list = contacts;
};
let inbox = Filter::new().kind(Kind::Custom(10050)).author(public_key).limit(1);
if let Ok(events) = client.get_events_of(vec![inbox], None).await {

View File

@@ -54,7 +54,7 @@ pub async fn get_chat_messages(id: String, state: State<'_, Nostr>) -> Result<Ve
let filter = Filter::new().kind(Kind::GiftWrap).pubkeys(vec![receiver_pk, sender_pk]);
let rumors = match client.get_events_of(vec![filter], Some(Duration::from_secs(10))).await {
let rumors = match client.database().query(vec![filter], Order::Desc).await {
Ok(events) => {
stream::iter(events)
.filter_map(|ev| async move {

View File

@@ -27,6 +27,7 @@ fn main() {
connect_account,
get_accounts,
get_metadata,
get_contact_list,
get_chats,
get_chat_messages,
connect_inbox,