feat: upgrade to rust nostr 0.30.0 and migrate to nostrdb

This commit is contained in:
2024-04-13 08:53:31 +07:00
parent a14aeaeb55
commit 89f577fbef
6 changed files with 283 additions and 277 deletions

548
src-tauri/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -11,7 +11,7 @@ rust-version = "1.68"
tauri-build = { version = "2.0.0-beta", features = [] }
[dependencies]
nostr-sdk = { version = "0.29", features = ["sqlite"] }
nostr-sdk = { version = "0.30", features = ["ndb"] }
tokio = { version = "1", features = ["full"] }
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }

View File

@@ -44,10 +44,10 @@ fn main() {
tauri::async_runtime::spawn(async move {
// Create nostr database connection
let sqlite = SQLiteDatabase::open(home_dir.join("Lume/lume.db")).await;
let ndb = NdbDatabase::open("./ndb");
// Create nostr connection
let client = match sqlite {
let client = match ndb {
Ok(db) => ClientBuilder::default().database(db).build(),
Err(_) => ClientBuilder::default().build(),
};

View File

@@ -226,7 +226,7 @@ pub async fn publish(
state: State<'_, Nostr>,
) -> Result<String, String> {
let client = &state.client;
let final_tags = tags.into_iter().map(|val| Tag::parse(val).unwrap());
let final_tags = tags.into_iter().map(|val| Tag::parse(&val).unwrap());
if let Ok(event_id) = client.publish_text_note(content, final_tags).await {
Ok(event_id.to_bech32().unwrap())