wip: basic support multi windows

This commit is contained in:
2024-02-16 09:58:07 +07:00
parent a0d9a729dd
commit 296b11b7b8
17 changed files with 214 additions and 118 deletions

View File

@@ -6,15 +6,14 @@ use tauri::State;
#[tauri::command(async)]
pub async fn get_event(id: &str, nostr: State<'_, Nostr>) -> Result<String, String> {
let client = &nostr.client;
let event_id;
if id.starts_with("note") {
event_id = EventId::from_bech32(id).unwrap();
} else if id.starts_with("nevent") {
event_id = Nip19Event::from_bech32(id).unwrap().event_id;
} else {
event_id = EventId::from_hex(id).unwrap();
}
let event_id: EventId = match Nip19::from_bech32(id) {
Ok(val) => match val {
Nip19::EventId(id) => id,
Nip19::Event(event) => event.event_id,
_ => panic!("not nip19"),
},
Err(_) => EventId::from_hex(id).unwrap(),
};
let filter = Filter::new().id(event_id);
let events = client

View File

@@ -6,15 +6,14 @@ use tauri::State;
#[tauri::command(async)]
pub async fn get_profile(id: &str, nostr: State<'_, Nostr>) -> Result<Metadata, ()> {
let client = &nostr.client;
let public_key;
if id.starts_with("nprofile1") {
public_key = XOnlyPublicKey::from_bech32(id).unwrap();
} else if id.starts_with("npub1") {
public_key = XOnlyPublicKey::from_bech32(id).unwrap();
} else {
public_key = XOnlyPublicKey::from_str(id).unwrap();
}
let public_key: XOnlyPublicKey = match Nip19::from_bech32(id) {
Ok(val) => match val {
Nip19::Pubkey(pubkey) => pubkey,
Nip19::Profile(profile) => profile.public_key,
_ => panic!("not nip19"),
},
Err(_) => XOnlyPublicKey::from_str(id).unwrap(),
};
let filter = Filter::new()
.author(public_key)