fix(persistence): guard parsing errors and preserve falsy configs (#850)
This commit is contained in:
+8
-1
@@ -1,5 +1,12 @@
|
||||
[workspace]
|
||||
members = [ "crates/tauri-plugin-ipc-audio-transcription-ort", "crates/tauri-plugin-ipc-audio-vad-ort", "crates/tauri-plugin-mcp", "crates/tauri-plugin-rdev", "crates/tauri-plugin-window-pass-through-on-hover", "crates/tauri-plugin-window-router-link" ]
|
||||
members = [
|
||||
"crates/tauri-plugin-ipc-audio-transcription-ort",
|
||||
"crates/tauri-plugin-ipc-audio-vad-ort",
|
||||
"crates/tauri-plugin-mcp",
|
||||
"crates/tauri-plugin-rdev",
|
||||
"crates/tauri-plugin-window-pass-through-on-hover",
|
||||
"crates/tauri-plugin-window-router-link"
|
||||
]
|
||||
resolver = "2"
|
||||
|
||||
[workspace.package]
|
||||
|
||||
@@ -7,7 +7,14 @@ import { app } from 'electron'
|
||||
import { throttle } from 'es-toolkit'
|
||||
|
||||
function parseOrFallback<T>(config: string, fallback: T | undefined): T | undefined {
|
||||
return safeDestr<T>(config) || fallback
|
||||
try {
|
||||
const parsed = safeDestr<T>(config)
|
||||
return parsed ?? fallback
|
||||
}
|
||||
catch (error) {
|
||||
console.warn('Invalid config persisted to disk, resetting to default', error)
|
||||
return fallback
|
||||
}
|
||||
}
|
||||
|
||||
const persistenceMap = new Map<string, any>()
|
||||
|
||||
Reference in New Issue
Block a user