fix(desktop): persist tray icon preference
This commit is contained in:
1 parent
3f64e830f8
commit
c124ce3b69
4 files changed
+22
-2
No files matched your search
@@ -756,6 +756,7 @@ function onLoginSuccess() {
|
|||||||
function initApp() {
|
function initApp() {
|
||||||
const t0 = performance.now();
|
const t0 = performance.now();
|
||||||
console.log("[STARTUP] initApp begin");
|
console.log("[STARTUP] initApp begin");
|
||||||
|
settingsStore.initDesktopSettings().catch(() => {});
|
||||||
savedSqlStore
|
savedSqlStore
|
||||||
.initFromStorage()
|
.initFromStorage()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
|||||||
@@ -335,6 +335,7 @@ impl Storage {
|
|||||||
show_tray_icon: settings
|
show_tray_icon: settings
|
||||||
.get("show_tray_icon")
|
.get("show_tray_icon")
|
||||||
.and_then(|value| value.as_bool())
|
.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),
|
.unwrap_or_else(|| DesktopSettings::default().show_tray_icon),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -1079,14 +1080,14 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[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 path = temp_db_path("desktop-settings-legacy-background");
|
||||||
let storage = Storage::open(&path).await.unwrap();
|
let storage = Storage::open(&path).await.unwrap();
|
||||||
let mut settings = serde_json::Map::new();
|
let mut settings = serde_json::Map::new();
|
||||||
settings.insert("run_in_background".to_string(), serde_json::Value::Bool(false));
|
settings.insert("run_in_background".to_string(), serde_json::Value::Bool(false));
|
||||||
storage.save_app_settings_json(&settings).await.unwrap();
|
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]
|
#[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\(\(\) => \{\}\);/);
|
||||||
|
});
|
||||||
Reference in new issue
Block a user