fix(app): keep tray preference persistence stable
This commit is contained in:
1 parent
bc41936e48
commit
a29b95b9fa
10 files changed
+100
-86
No files matched your search
@@ -1,10 +1,10 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use dbx_core::storage::DesktopSettings;
|
||||
use tauri::{AppHandle, Manager, State};
|
||||
use tauri::{AppHandle, State};
|
||||
|
||||
use super::connection::AppState;
|
||||
use crate::{apply_desktop_tray_preference, WindowBehaviorState};
|
||||
use crate::apply_desktop_tray_preference;
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn load_desktop_settings(state: State<'_, Arc<AppState>>) -> Result<DesktopSettings, String> {
|
||||
@@ -18,8 +18,8 @@ pub async fn save_desktop_settings(
|
||||
settings: DesktopSettings,
|
||||
) -> Result<(), String> {
|
||||
state.storage.save_desktop_settings(&settings).await?;
|
||||
if let Some(window_behavior) = app.try_state::<WindowBehaviorState>() {
|
||||
window_behavior.set_run_in_background(settings.run_in_background);
|
||||
if let Err(err) = apply_desktop_tray_preference(&app, settings.show_tray_icon) {
|
||||
eprintln!("Failed to apply desktop tray preference: {err}");
|
||||
}
|
||||
apply_desktop_tray_preference(&app, settings.run_in_background).map_err(|err| err.to_string())
|
||||
Ok(())
|
||||
}
|
||||
Reference in new issue
Block a user