chore: improve search (#83)

* .

* .

* wip: add nip05 search

* add nip05 search

* .

* support cancel search

* .
This commit is contained in:
reya
2025-07-10 09:03:54 +07:00
committed by GitHub
parent 8bfad30a99
commit 2e3a4b3634
10 changed files with 377 additions and 291 deletions

View File

@@ -2,6 +2,7 @@ use std::collections::HashSet;
use std::hash::{DefaultHasher, Hash, Hasher};
use std::sync::Arc;
use anyhow::anyhow;
use gpui::{Image, ImageFormat};
use itertools::Itertools;
use nostr_sdk::prelude::*;
@@ -32,6 +33,16 @@ pub fn room_hash(event: &Event) -> u64 {
hasher.finish()
}
pub fn parse_pubkey_from_str(content: &str) -> Result<PublicKey, anyhow::Error> {
if content.starts_with("nprofile1") {
Ok(Nip19Profile::from_bech32(content)?.public_key)
} else if content.starts_with("npub1") {
Ok(PublicKey::parse(content)?)
} else {
Err(anyhow!("Invalid public key"))
}
}
pub fn string_to_qr(data: &str) -> Option<Arc<Image>> {
let Ok(bytes) = qrcode_generator::to_png_to_vec_from_str(data, QrCodeEcc::Medium, 256) else {
return None;