fix(persistence-service): update schemas found to differ in runtime (#3671)
This commit is contained in:
@@ -244,9 +244,13 @@ export class PersistenceService extends Service {
|
|||||||
private setupSettingsPersistence() {
|
private setupSettingsPersistence() {
|
||||||
const settingsKey = "settings"
|
const settingsKey = "settings"
|
||||||
let settingsData = JSON.parse(
|
let settingsData = JSON.parse(
|
||||||
window.localStorage.getItem(settingsKey) || "{}"
|
window.localStorage.getItem(settingsKey) ?? "null"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (!settingsData) {
|
||||||
|
settingsData = getDefaultSettings()
|
||||||
|
}
|
||||||
|
|
||||||
// Validate data read from localStorage
|
// Validate data read from localStorage
|
||||||
const result = SETTINGS_SCHEMA.safeParse(settingsData)
|
const result = SETTINGS_SCHEMA.safeParse(settingsData)
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ const SettingsDefSchema = z.object({
|
|||||||
httpUser: z.boolean(),
|
httpUser: z.boolean(),
|
||||||
httpPassword: z.boolean(),
|
httpPassword: z.boolean(),
|
||||||
bearerToken: z.boolean(),
|
bearerToken: z.boolean(),
|
||||||
oauth2Token: z.boolean(),
|
oauth2Token: z.optional(z.boolean()),
|
||||||
}),
|
}),
|
||||||
THEME_COLOR: ThemeColorSchema,
|
THEME_COLOR: ThemeColorSchema,
|
||||||
BG_COLOR: BgColorSchema,
|
BG_COLOR: BgColorSchema,
|
||||||
@@ -103,13 +103,10 @@ export const LOCAL_STATE_SCHEMA = z.union([
|
|||||||
.strict(),
|
.strict(),
|
||||||
])
|
])
|
||||||
|
|
||||||
export const SETTINGS_SCHEMA = z.union([
|
export const SETTINGS_SCHEMA = SettingsDefSchema.extend({
|
||||||
z.object({}).strict(),
|
EXTENSIONS_ENABLED: z.optional(z.boolean()),
|
||||||
SettingsDefSchema.extend({
|
PROXY_ENABLED: z.optional(z.boolean()),
|
||||||
EXTENSIONS_ENABLED: z.optional(z.boolean()),
|
})
|
||||||
PROXY_ENABLED: z.optional(z.boolean()),
|
|
||||||
}),
|
|
||||||
])
|
|
||||||
|
|
||||||
export const REST_HISTORY_ENTRY_SCHEMA = z
|
export const REST_HISTORY_ENTRY_SCHEMA = z
|
||||||
.object({
|
.object({
|
||||||
@@ -208,7 +205,7 @@ export const MQTT_REQUEST_SCHEMA = z.nullable(
|
|||||||
z
|
z
|
||||||
.object({
|
.object({
|
||||||
endpoint: z.string(),
|
endpoint: z.string(),
|
||||||
clientID: z.string(),
|
clientID: z.optional(z.string()),
|
||||||
})
|
})
|
||||||
.strict()
|
.strict()
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user