feat: new post editor

This commit is contained in:
2024-09-26 10:57:58 +07:00
parent bacfaed48a
commit 0a8eed9a46
8 changed files with 382 additions and 464 deletions

View File

@@ -20,6 +20,14 @@ pub struct Profile {
website: Option<String>,
}
#[derive(Clone, Serialize, Deserialize, Type)]
pub struct Mention {
pubkey: String,
avatar: String,
display_name: String,
name: String,
}
#[tauri::command]
#[specta::specta]
pub async fn get_profile(id: Option<String>, state: State<'_, Nostr>) -> Result<String, String> {
@@ -195,6 +203,36 @@ pub async fn toggle_contact(
}
}
#[tauri::command]
#[specta::specta]
pub async fn get_mention_list(state: State<'_, Nostr>) -> Result<Vec<Mention>, String> {
let client = &state.client;
let filter = Filter::new().kind(Kind::Metadata);
let events = client
.database()
.query(vec![filter])
.await
.map_err(|e| e.to_string())?;
let data: Vec<Mention> = events
.iter()
.map(|event| {
let pubkey = event.pubkey.to_bech32().unwrap();
let metadata = Metadata::from_json(&event.content).unwrap_or(Metadata::new());
Mention {
pubkey,
avatar: metadata.picture.unwrap_or_else(|| "".to_string()),
display_name: metadata.display_name.unwrap_or_else(|| "".to_string()),
name: metadata.name.unwrap_or_else(|| "".to_string()),
}
})
.collect();
Ok(data)
}
#[tauri::command]
#[specta::specta]
pub async fn set_lume_store(

View File

@@ -115,6 +115,7 @@ fn main() {
is_contact_list_empty,
check_contact,
toggle_contact,
get_mention_list,
get_lume_store,
set_lume_store,
set_wallet,