From a2a502cc6e6a6715c232eb320dd64fe5df6b7fbd Mon Sep 17 00:00:00 2001 From: 0xgingi <0xgingi@0xgingi.com> Date: Wed, 13 Nov 2024 11:56:36 -0500 Subject: [PATCH] v0.1.3 * Hide CLI on Windows * Refresh automatically on sync * Move Database and Config File to Roaming instead of local appdata to avoid deletion of data on nsis upgrade --- src-tauri/Cargo.toml | 5 +++++ src-tauri/src/main.rs | 22 ++++++++-------------- src-tauri/tauri.conf.json | 16 +++++++++++++--- src/App.tsx | 2 +- src/components/SyncSettings.tsx | 12 +++++++++++- 5 files changed, 38 insertions(+), 19 deletions(-) diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 2cc3947..a496924 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -26,3 +26,8 @@ reqwest = { version = "0.11", features = ["json"] } tokio = { version = "1.28", features = ["full"] } futures = "0.3" rand = "0.8" + +[[bin]] +name = "rusty-notes" +path = "src/main.rs" +windows-subsystem = "windows" diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index ec0b041..baa5956 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -1,3 +1,4 @@ +#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] mod types; mod crypto; mod sync; @@ -36,12 +37,7 @@ fn get_settings_path(app_handle: &AppHandle) -> PathBuf { #[tauri::command] async fn get_sync_settings(app_handle: AppHandle) -> Result { - let app_dir = app_handle - .path() - .app_local_data_dir() - .expect("Failed to get app data directory"); - let settings_path = app_dir.join("sync_settings.json"); - + let settings_path = get_settings_path(&app_handle); println!("Loading settings from: {:?}", settings_path); if settings_path.exists() { @@ -61,15 +57,13 @@ async fn get_sync_settings(app_handle: AppHandle) -> Result Result<(), String> { - let app_dir = app_handle - .path() - .app_local_data_dir() - .expect("Failed to get app data directory"); + let settings_path = get_settings_path(&app_handle); - fs::create_dir_all(&app_dir) - .map_err(|e| format!("Failed to create settings directory: {}", e))?; + if let Some(parent) = settings_path.parent() { + fs::create_dir_all(parent) + .map_err(|e| format!("Failed to create settings directory: {}", e))?; + } - let settings_path = app_dir.join("sync_settings.json"); println!("Saving settings to: {:?}", settings_path); let settings_str = serde_json::to_string_pretty(&settings) @@ -85,7 +79,7 @@ async fn save_sync_settings(app_handle: AppHandle, settings: SyncSettings) -> Re fn initialize_database(app_handle: &AppHandle) -> Result { let app_dir = app_handle .path() - .app_local_data_dir() + .app_data_dir() .expect("Failed to get app local data directory"); fs::create_dir_all(&app_dir).expect("Failed to create app data directory"); diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 9c97c62..71fd314 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -14,7 +14,8 @@ { "title": "rusty-notes", "width": 800, - "height": 600 + "height": 600, + "visible": true } ], "security": { @@ -30,6 +31,15 @@ "icons/128x128@2x.png", "icons/icon.icns", "icons/icon.ico" - ] + ], + "windows": { + "webviewInstallMode": { + "type": "downloadBootstrapper", + "silent": true + }, + "nsis": { + "installMode": "currentUser" + } + } } -} +} \ No newline at end of file diff --git a/src/App.tsx b/src/App.tsx index 5889153..f9f3689 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -338,7 +338,7 @@ async function handleSave() { title="Sync Settings" size="lg" > - + ); diff --git a/src/components/SyncSettings.tsx b/src/components/SyncSettings.tsx index a800184..866d01a 100644 --- a/src/components/SyncSettings.tsx +++ b/src/components/SyncSettings.tsx @@ -26,7 +26,11 @@ const DEFAULT_SERVERS = [ { label: 'Local Server', value: 'http://localhost:3222' }, ]; -export function SyncSettings() { +interface SyncSettingsProps { + onSync?: () => Promise; +} + +export function SyncSettings({ onSync }: SyncSettingsProps) { const [seedPhrase, setSeedPhrase] = useState(''); const [autoSync, setAutoSync] = useState(false); const [showNewSeedPhrase, setShowNewSeedPhrase] = useState(false); @@ -180,6 +184,12 @@ export function SyncSettings() { seedPhrase, serverUrl: selectedServer }); + + // Call the onSync callback after successful sync + if (onSync) { + await onSync(); + } + notifications.show({ title: 'Success', message: 'Notes synced successfully',