|
@ -109,9 +109,6 @@ export async function retrieveSettingsForActiveAccount(): Promise<Settings> { |
|
|
const defaultSettings = await retrieveSettingsForDefaultAccount(); |
|
|
const defaultSettings = await retrieveSettingsForDefaultAccount(); |
|
|
// If no active DID, return defaults
|
|
|
// If no active DID, return defaults
|
|
|
if (!defaultSettings.activeDid) { |
|
|
if (!defaultSettings.activeDid) { |
|
|
logConsoleAndDb( |
|
|
|
|
|
"[databaseUtil] No active DID found, returning default settings", |
|
|
|
|
|
); |
|
|
|
|
|
return defaultSettings; |
|
|
return defaultSettings; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -124,9 +121,7 @@ export async function retrieveSettingsForActiveAccount(): Promise<Settings> { |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
if (!result?.values?.length) { |
|
|
if (!result?.values?.length) { |
|
|
logConsoleAndDb( |
|
|
// we created DID-specific settings when generated or imported, so this shouldn't happen
|
|
|
`[databaseUtil] No account-specific settings found for ${defaultSettings.activeDid}`, |
|
|
|
|
|
); |
|
|
|
|
|
return defaultSettings; |
|
|
return defaultSettings; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -136,18 +131,6 @@ export async function retrieveSettingsForActiveAccount(): Promise<Settings> { |
|
|
result.values, |
|
|
result.values, |
|
|
)[0] as Settings; |
|
|
)[0] as Settings; |
|
|
|
|
|
|
|
|
// Debug: Check the actual data types from SQLite
|
|
|
|
|
|
logConsoleAndDb( |
|
|
|
|
|
`[DEBUG] Raw SQLite data types for ${defaultSettings.activeDid}:`, |
|
|
|
|
|
false, |
|
|
|
|
|
); |
|
|
|
|
|
Object.entries(overrideSettings).forEach(([key, value]) => { |
|
|
|
|
|
logConsoleAndDb( |
|
|
|
|
|
`[DEBUG] - ${key}: ${typeof value} = ${JSON.stringify(value)}`, |
|
|
|
|
|
false, |
|
|
|
|
|
); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const overrideSettingsFiltered = Object.fromEntries( |
|
|
const overrideSettingsFiltered = Object.fromEntries( |
|
|
Object.entries(overrideSettings).filter(([_, v]) => v !== null), |
|
|
Object.entries(overrideSettings).filter(([_, v]) => v !== null), |
|
|
); |
|
|
); |
|
@ -419,19 +402,11 @@ export function parseJsonField<T>(value: unknown, defaultValue: T): T { |
|
|
try { |
|
|
try { |
|
|
// If already an object (web SQLite auto-parsed), return as-is
|
|
|
// If already an object (web SQLite auto-parsed), return as-is
|
|
|
if (typeof value === "object" && value !== null) { |
|
|
if (typeof value === "object" && value !== null) { |
|
|
logConsoleAndDb( |
|
|
|
|
|
`[DEBUG] JSON field is already an object (auto-parsed by web SQLite), skipping parse`, |
|
|
|
|
|
false, |
|
|
|
|
|
); |
|
|
|
|
|
return value as T; |
|
|
return value as T; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// If it's a string (Capacitor SQLite or fallback), parse it
|
|
|
// If it's a string (Capacitor SQLite or fallback), parse it
|
|
|
if (typeof value === "string") { |
|
|
if (typeof value === "string") { |
|
|
logConsoleAndDb( |
|
|
|
|
|
`[DEBUG] JSON field is a string, parsing JSON (Capacitor SQLite or web fallback)`, |
|
|
|
|
|
false, |
|
|
|
|
|
); |
|
|
|
|
|
return JSON.parse(value) as T; |
|
|
return JSON.parse(value) as T; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -440,11 +415,6 @@ export function parseJsonField<T>(value: unknown, defaultValue: T): T { |
|
|
return defaultValue; |
|
|
return defaultValue; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Unexpected type, log and return default
|
|
|
|
|
|
logConsoleAndDb( |
|
|
|
|
|
`[DEBUG] JSON field has unexpected type: ${typeof value}, returning default`, |
|
|
|
|
|
true, |
|
|
|
|
|
); |
|
|
|
|
|
return defaultValue; |
|
|
return defaultValue; |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
logConsoleAndDb( |
|
|
logConsoleAndDb( |
|
|