chore: update deps

This commit is contained in:
2024-09-14 08:05:25 +07:00
parent a8e707ae8a
commit 278773433d
10 changed files with 1222 additions and 706 deletions

614
src-tauri/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -14,7 +14,7 @@ tauri-build = { version = "2.0.0-rc", features = [] }
[dependencies]
nostr-sdk = { git = "https://github.com/rust-nostr/nostr", features = [
"sqlite",
"lmdb",
] }
tauri = { version = "2.0.0-rc", features = [
"tray-icon",
@@ -32,13 +32,13 @@ tauri-plugin-updater = "2.0.0-rc"
tauri-plugin-process = "2.0.0-rc"
tauri-plugin-fs = "2.0.0-rc"
tauri-plugin-notification = "2.0.0-rc"
tauri-plugin-decorum = "1.0.0"
tauri-plugin-decorum = "1.1.0"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
keyring = { version = "3", features = [
"apple-native",
"windows-native",
"sync-secret-service",
"linux-native",
] }
keyring-search = "1.2.0"
itertools = "0.13.0"

View File

@@ -142,7 +142,7 @@ pub async fn connect_account(uri: String, state: State<'_, Nostr>) -> Result<Str
Ok(bunker_uri) => {
// Local user
let app_keys = Keys::generate();
let app_secret = app_keys.secret_key().to_string();
let app_secret = app_keys.secret_key().to_secret_hex();
// Get remote user
let remote_user = bunker_uri.signer_public_key().unwrap();
@@ -275,7 +275,7 @@ pub async fn login(
{
if let Some(event) = events.into_iter().next() {
let urls = event
.tags()
.tags
.iter()
.filter_map(|tag| {
if let Some(TagStandard::Relay(relay)) = tag.as_standardized() {

View File

@@ -14,7 +14,7 @@ pub async fn get_chats(state: State<'_, Nostr>) -> Result<Vec<String>, String> {
let filter = Filter::new().kind(Kind::PrivateDirectMessage).pubkey(public_key);
match client.database().query(vec![filter], Order::Asc).await {
match client.database().query(vec![filter]).await {
Ok(events) => {
let ev = events
.into_iter()
@@ -44,7 +44,7 @@ pub async fn get_chat_messages(id: String, state: State<'_, Nostr>) -> Result<Ve
let sender_filter =
Filter::new().kind(Kind::PrivateDirectMessage).author(receiver).pubkey(sender);
match client.database().query(vec![recv_filter, sender_filter], Order::Desc).await {
match client.database().query(vec![recv_filter, sender_filter]).await {
Ok(events) => {
let ev = events.into_iter().map(|ev| ev.as_json()).collect::<Vec<_>>();
Ok(ev)

View File

@@ -8,32 +8,6 @@ use tauri::{Manager, State};
use crate::Nostr;
async fn connect_nip65_relays(public_key: PublicKey, client: &Client) -> Vec<String> {
let filter = Filter::new().author(public_key).kind(Kind::RelayList).limit(1);
let mut relay_list: Vec<String> = Vec::new();
if let Ok(events) =
client.get_events_of(vec![filter], EventSource::relays(Some(Duration::from_secs(3)))).await
{
if let Some(event) = events.first() {
for (url, ..) in nip65::extract_relay_list(event) {
let _ = client.add_relay(url).await;
relay_list.push(url.to_string())
}
}
};
relay_list
}
async fn disconnect_nip65_relays(relays: Vec<String>, client: &Client) {
for relay in relays.iter() {
if let Err(e) = client.disconnect_relay(relay).await {
println!("Disconnect failed: {}", e)
}
}
}
#[tauri::command]
#[specta::specta]
pub fn get_bootstrap_relays(app: tauri::AppHandle) -> Result<Vec<String>, String> {
@@ -75,7 +49,7 @@ pub async fn collect_inbox_relays(
Ok(events) => {
if let Some(event) = events.into_iter().next() {
let urls = event
.tags()
.tags
.iter()
.filter_map(|tag| {
if let Some(TagStandard::Relay(relay)) = tag.as_standardized() {

View File

@@ -14,7 +14,6 @@ use std::{
time::Duration,
};
use tauri::{async_runtime::Mutex, Manager};
#[cfg(not(target_os = "linux"))]
use tauri_plugin_decorum::WebviewWindowExt;
use tauri_specta::{collect_commands, Builder};
@@ -74,7 +73,7 @@ fn main() {
let main_window = app.get_webview_window("main").unwrap();
// Set custom decoration
#[cfg(target_os = "windows")]
#[cfg(not(target_os = "macos"))]
main_window.create_overlay_titlebar().unwrap();
// Set traffic light inset
@@ -97,11 +96,13 @@ fn main() {
let (client, bootstrap_relays) = tauri::async_runtime::block_on(async move {
// Create data folder if not exist
let dir = handle.path().app_config_dir().expect("App config directory not found.");
let _ = fs::create_dir_all(dir.clone());
let dir =
handle.path().app_config_dir().expect("Error: config directory not found.");
let _ = fs::create_dir_all(&dir);
// Setup database
let database = SQLiteDatabase::open(dir.join("nostr.db")).await.expect("Error.");
let database = NostrLMDB::open(dir.join("nostr-lmdb"))
.expect("Error: cannot create database.");
// Setup nostr client
let opts = Options::new()
@@ -131,7 +132,7 @@ fn main() {
} else {
RelayOptions::new().write(true).read(false)
};
let _ = client.add_relay_with_opts(relay, opts).await;
let _ = client.pool().add_relay(relay, opts).await;
}
Err(_) => {
println!("Connecting to relay...: {}", relay);