chore: fix build

This commit is contained in:
2024-02-10 11:19:18 +07:00
parent 739ba63e6c
commit 35c5b5fb78
10 changed files with 136 additions and 43 deletions

View File

@@ -126,6 +126,7 @@ fn main() {
Ok(())
})
.plugin(tauri_plugin_store::Builder::default().build())
.plugin(tauri_plugin_theme::init(ctx.config_mut()))
.plugin(tauri_plugin_clipboard_manager::init())
.plugin(tauri_plugin_dialog::init())

View File

@@ -4,7 +4,7 @@ use std::{str::FromStr, time::Duration};
use tauri::State;
#[tauri::command(async)]
pub async fn get_event(id: &str, nostr: State<'_, Nostr>) -> Result<String, ()> {
pub async fn get_event(id: &str, nostr: State<'_, Nostr>) -> Result<String, String> {
let client = &nostr.client;
let event_id;
@@ -21,9 +21,12 @@ pub async fn get_event(id: &str, nostr: State<'_, Nostr>) -> Result<String, ()>
.get_events_of(vec![filter], Some(Duration::from_secs(10)))
.await
.expect("Get event failed");
let event = events.first().unwrap().as_json();
Ok(event)
if let Some(event) = events.first() {
Ok(event.as_json())
} else {
Err("Event not found".into())
}
}
#[tauri::command(async)]
@@ -48,12 +51,14 @@ pub async fn get_text_events(
.limit(limit)
.until(final_until);
let events = client
if let Ok(events) = client
.get_events_of(vec![filter], Some(Duration::from_secs(10)))
.await
.expect("Get event failed");
Ok(events)
{
Ok(events)
} else {
Err(())
}
}
#[tauri::command(async)]
@@ -62,12 +67,14 @@ pub async fn get_event_thread(id: &str, nostr: State<'_, Nostr>) -> Result<Vec<E
let event_id = EventId::from_hex(id).unwrap();
let filter = Filter::new().kinds(vec![Kind::TextNote]).event(event_id);
let events = client
if let Ok(events) = client
.get_events_of(vec![filter], Some(Duration::from_secs(10)))
.await
.expect("Get event failed");
Ok(events)
{
Ok(events)
} else {
Err(())
}
}
#[tauri::command(async)]

View File

@@ -26,8 +26,10 @@ pub async fn get_profile(id: &str, nostr: State<'_, Nostr>) -> Result<Metadata,
.await
.expect("Get metadata failed");
let event = events.first().unwrap();
let metadata: Metadata = Metadata::from_json(&event.content).unwrap();
Ok(metadata)
if let Some(event) = events.first() {
let metadata: Metadata = Metadata::from_json(&event.content).unwrap();
Ok(metadata)
} else {
Err(())
}
}