feat: add zap setup screen
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
"splash",
|
||||
"editor",
|
||||
"settings",
|
||||
"nwc",
|
||||
"zap",
|
||||
"event-*",
|
||||
"user-*",
|
||||
"column-*"
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"desktop-capability":{"identifier":"desktop-capability","description":"Capability for the desktop","local":true,"windows":["main","splash","editor","settings","event-*","user-*","column-*"],"permissions":["path:default","event:default","window:default","app:default","resources:default","menu:default","tray:default","notification:allow-is-permission-granted","notification:allow-request-permission","notification:default","os:allow-locale","os:allow-platform","updater:allow-check","updater:default","window:allow-start-dragging","store:allow-get","clipboard-manager:allow-write","clipboard-manager:allow-read","webview:allow-create-webview-window","webview:allow-create-webview","dialog:allow-open","fs:allow-read-file","shell:allow-open",{"identifier":"http:default","allow":[{"url":"http://**/"},{"url":"https://**/"}]},{"identifier":"fs:allow-read-text-file","allow":[{"path":"$RESOURCE/locales/*"}]}],"platforms":["linux","macOS","windows"]}}
|
||||
{"desktop-capability":{"identifier":"desktop-capability","description":"Capability for the desktop","local":true,"windows":["main","splash","editor","settings","nwc","zap","event-*","user-*","column-*"],"permissions":["path:default","event:default","window:default","app:default","resources:default","menu:default","tray:default","notification:allow-is-permission-granted","notification:allow-request-permission","notification:default","os:allow-locale","os:allow-platform","updater:allow-check","updater:default","window:allow-start-dragging","store:allow-get","clipboard-manager:allow-write","clipboard-manager:allow-read","webview:allow-create-webview-window","webview:allow-create-webview","dialog:allow-open","fs:allow-read-file","shell:allow-open",{"identifier":"http:default","allow":[{"url":"http://**/"},{"url":"https://**/"}]},{"identifier":"fs:allow-read-text-file","allow":[{"path":"$RESOURCE/locales/*"}]}],"platforms":["linux","macOS","windows"]}}
|
||||
@@ -103,6 +103,7 @@ fn main() {
|
||||
nostr::metadata::get_settings,
|
||||
nostr::metadata::get_nwc_status,
|
||||
nostr::metadata::set_nwc,
|
||||
nostr::metadata::nwc_status,
|
||||
nostr::metadata::zap_profile,
|
||||
nostr::metadata::zap_event,
|
||||
nostr::event::get_event,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use crate::Nostr;
|
||||
use keyring::Entry;
|
||||
use nostr_sdk::prelude::*;
|
||||
use std::{str::FromStr, time::Duration};
|
||||
use tauri::State;
|
||||
@@ -285,18 +286,30 @@ pub async fn get_nwc_status(state: State<'_, Nostr>) -> Result<bool, ()> {
|
||||
pub async fn set_nwc(uri: &str, state: State<'_, Nostr>) -> Result<bool, String> {
|
||||
let client = &state.client;
|
||||
|
||||
if let Ok(uri) = NostrWalletConnectURI::from_str(&uri) {
|
||||
if let Ok(nwc) = NWC::new(uri).await {
|
||||
if let Ok(nwc_uri) = NostrWalletConnectURI::from_str(&uri) {
|
||||
if let Ok(nwc) = NWC::new(nwc_uri).await {
|
||||
let keyring = Entry::new("Lume Secret Storage", "NWC").unwrap();
|
||||
let _ = keyring.set_password(uri);
|
||||
let _ = client.set_zapper(nwc);
|
||||
|
||||
Ok(true)
|
||||
} else {
|
||||
Ok(false)
|
||||
Err("URI is not valid".into())
|
||||
}
|
||||
} else {
|
||||
Err("Set NWC failed".into())
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn nwc_status(state: State<'_, Nostr>) -> Result<bool, bool> {
|
||||
let client = &state.client;
|
||||
match client.zapper().await {
|
||||
Ok(_) => Ok(true),
|
||||
Err(_) => Err(false),
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn zap_profile(
|
||||
id: &str,
|
||||
|
||||
Reference in New Issue
Block a user