fix(desktop): persist tray icon preference
This commit is contained in:
parent
3f64e830f8
commit
c124ce3b69
|
|
@ -756,6 +756,7 @@ function onLoginSuccess() {
|
|||
function initApp() {
|
||||
const t0 = performance.now();
|
||||
console.log("[STARTUP] initApp begin");
|
||||
settingsStore.initDesktopSettings().catch(() => {});
|
||||
savedSqlStore
|
||||
.initFromStorage()
|
||||
.then(() => {
|
||||
|
|
|
|||
|
|
@ -335,6 +335,7 @@ impl Storage {
|
|||
show_tray_icon: settings
|
||||
.get("show_tray_icon")
|
||||
.and_then(|value| value.as_bool())
|
||||
.or_else(|| settings.get("run_in_background").and_then(|value| value.as_bool()))
|
||||
.unwrap_or_else(|| DesktopSettings::default().show_tray_icon),
|
||||
})
|
||||
}
|
||||
|
|
@ -1079,14 +1080,14 @@ mod tests {
|
|||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn desktop_settings_ignore_legacy_background_preference() {
|
||||
async fn desktop_settings_fall_back_to_legacy_background_preference() {
|
||||
let path = temp_db_path("desktop-settings-legacy-background");
|
||||
let storage = Storage::open(&path).await.unwrap();
|
||||
let mut settings = serde_json::Map::new();
|
||||
settings.insert("run_in_background".to_string(), serde_json::Value::Bool(false));
|
||||
storage.save_app_settings_json(&settings).await.unwrap();
|
||||
|
||||
assert_eq!(storage.load_desktop_settings().await.unwrap(), DesktopSettings { show_tray_icon: true });
|
||||
assert_eq!(storage.load_desktop_settings().await.unwrap(), DesktopSettings { show_tray_icon: false });
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
|
||||
test("desktop settings fall back to the legacy run_in_background preference during upgrades", () => {
|
||||
const source = readFileSync("crates/dbx-core/src/storage.rs", "utf8");
|
||||
|
||||
assert.match(source, /\.or_else\(\|\| settings\.get\("run_in_background"\)\.and_then\(\|value\| value\.as_bool\(\)\)\)/);
|
||||
});
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
|
||||
test("app startup eagerly loads desktop settings so tray preference is not reset in the UI", () => {
|
||||
const source = readFileSync("apps/desktop/src/App.vue", "utf8");
|
||||
|
||||
assert.match(source, /settingsStore\.initDesktopSettings\(\)\.catch\(\(\) => \{\}\);/);
|
||||
});
|
||||
Loading…
Reference in New Issue