@ -343,7 +343,10 @@ export async function debugSettingsData(did?: string): Promise<void> {
// Get all settings records
const allSettings = await platform . dbQuery ( "SELECT * FROM settings" ) ;
logConsoleAndDb ( ` [DEBUG] Total settings records: ${ allSettings ? . values ? . length || 0 } ` , false ) ;
logConsoleAndDb (
` [DEBUG] Total settings records: ${ allSettings ? . values ? . length || 0 } ` ,
false ,
) ;
if ( allSettings ? . values ? . length ) {
allSettings . values . forEach ( ( row , index ) = > {
@ -354,28 +357,48 @@ export async function debugSettingsData(did?: string): Promise<void> {
logConsoleAndDb ( ` [DEBUG] - activeDid: ${ settings . activeDid } ` , false ) ;
if ( settings . searchBoxes ) {
logConsoleAndDb ( ` [DEBUG] - searchBoxes type: ${ typeof settings . searchBoxes } ` , false ) ;
logConsoleAndDb ( ` [DEBUG] - searchBoxes value: ${ String ( settings . searchBoxes ) } ` , false ) ;
logConsoleAndDb (
` [DEBUG] - searchBoxes type: ${ typeof settings . searchBoxes } ` ,
false ,
) ;
logConsoleAndDb (
` [DEBUG] - searchBoxes value: ${ String ( settings . searchBoxes ) } ` ,
false ,
) ;
// Try to parse it
try {
const parsed = JSON . parse ( String ( settings . searchBoxes ) ) ;
logConsoleAndDb ( ` [DEBUG] - searchBoxes parsed successfully: ${ JSON . stringify ( parsed ) } ` , false ) ;
logConsoleAndDb (
` [DEBUG] - searchBoxes parsed successfully: ${ JSON . stringify ( parsed ) } ` ,
false ,
) ;
} catch ( parseError ) {
logConsoleAndDb ( ` [DEBUG] - searchBoxes parse error: ${ parseError } ` , true ) ;
logConsoleAndDb (
` [DEBUG] - searchBoxes parse error: ${ parseError } ` ,
true ,
) ;
}
}
logConsoleAndDb ( ` [DEBUG] - Full record: ${ JSON . stringify ( settings , null , 2 ) } ` , false ) ;
logConsoleAndDb (
` [DEBUG] - Full record: ${ JSON . stringify ( settings , null , 2 ) } ` ,
false ,
) ;
} ) ;
}
// If specific DID provided, also check accounts table
if ( did ) {
const account = await platform . dbQuery ( "SELECT * FROM accounts WHERE did = ?" , [ did ] ) ;
logConsoleAndDb ( ` [DEBUG] Account for ${ did } : ${ JSON . stringify ( account , null , 2 ) } ` , false ) ;
const account = await platform . dbQuery (
"SELECT * FROM accounts WHERE did = ?" ,
[ did ] ,
) ;
logConsoleAndDb (
` [DEBUG] Account for ${ did } : ${ JSON . stringify ( account , null , 2 ) } ` ,
false ,
) ;
}
} catch ( error ) {
logConsoleAndDb ( ` [DEBUG] Error inspecting settings data: ${ error } ` , true ) ;
}
@ -392,13 +415,10 @@ export async function debugSettingsData(did?: string): Promise<void> {
* @returns Parsed object or default value
* @author Matthew Raymer
* /
export function parseJsonField < T > (
value : unknown ,
defaultValue : T
) : T {
export function parseJsonField < T > ( value : unknown , defaultValue : T ) : T {
try {
// 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 ,
@ -407,7 +427,7 @@ export function parseJsonField<T>(
}
// 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 ,
@ -426,7 +446,6 @@ export function parseJsonField<T>(
true ,
) ;
return defaultValue ;
} catch ( error ) {
logConsoleAndDb (
` [databaseUtil] Failed to parse JSON field: ${ error } ` ,