@ -437,30 +437,18 @@ export const PlatformServiceMixin = {
} ,
/ * *
* Utility method for retrieving and parsing settings
* Utility method for retrieving master settings
* Common pattern used across many components
* /
async $getSettings (
key : string ,
async $getMasterSettings (
fallback : Settings | null = null ,
) : Promise < Settings | null > {
try {
// FIXED: Use specific queries instead of ambiguous OR condition
let result ;
// Check if this is a master settings key (numeric or "1")
if ( key === MASTER_SETTINGS_KEY || key === "1" || ! isNaN ( Number ( key ) ) ) {
// Master settings: query by id
result = await this . $dbQuery ( "SELECT * FROM settings WHERE id = ?" , [
key ,
] ) ;
} else {
// Account settings: query by accountDid
result = await this . $dbQuery (
"SELECT * FROM settings WHERE accountDid = ?" ,
[ key ] ,
const result = await this . $dbQuery (
"SELECT * FROM settings WHERE id = ?" ,
[ MASTER_SETTINGS_KEY ] ,
) ;
}
if ( ! result ? . values ? . length ) {
return fallback ;
@ -484,8 +472,7 @@ export const PlatformServiceMixin = {
return settings ;
} catch ( error ) {
logger . error ( ` [Settings Trace] ❌ Failed to get settings: ` , {
key ,
logger . error ( ` [Settings Trace] ❌ Failed to get master settings: ` , {
error ,
} ) ;
return fallback ;
@ -503,10 +490,7 @@ export const PlatformServiceMixin = {
) : Promise < Settings > {
try {
// Get default settings
const defaultSettings = await this . $getSettings (
defaultKey ,
defaultFallback ,
) ;
const defaultSettings = await this . $getMasterSettings ( defaultFallback ) ;
// If no account DID, return defaults
if ( ! accountDid ) {
@ -769,7 +753,7 @@ export const PlatformServiceMixin = {
* @returns Fresh settings object from database
* /
async $settings ( defaults : Settings = { } ) : Promise < Settings > {
const settings = await this . $getSettings ( MASTER_SETTINGS_KEY , defaults ) ;
const settings = await this . $getMaster Settings ( defaults ) ;
if ( ! settings ) {
return defaults ;
@ -802,10 +786,7 @@ export const PlatformServiceMixin = {
) : Promise < Settings > {
try {
// Get default settings first
const defaultSettings = await this . $getSettings (
MASTER_SETTINGS_KEY ,
defaults ,
) ;
const defaultSettings = await this . $getMasterSettings ( defaults ) ;
if ( ! defaultSettings ) {
return defaults ;
@ -1590,10 +1571,7 @@ export const PlatformServiceMixin = {
async $debugMergedSettings ( did : string ) : Promise < void > {
try {
// Get default settings
const defaultSettings = await this . $getSettings (
MASTER_SETTINGS_KEY ,
{ } ,
) ;
const defaultSettings = await this . $getMasterSettings ( { } ) ;
logger . info (
` [PlatformServiceMixin] Default settings: ` ,
defaultSettings ,
@ -1640,10 +1618,7 @@ export interface IPlatformServiceMixin {
) : Promise < QueryExecResult | undefined > ;
$dbExec ( sql : string , params? : unknown [ ] ) : Promise < DatabaseExecResult > ;
$dbGetOneRow ( sql : string , params? : unknown [ ] ) : Promise < unknown [ ] | undefined > ;
$getSettings (
key : string ,
fallback? : Settings | null ,
) : Promise < Settings | null > ;
$getMasterSettings ( fallback? : Settings | null ) : Promise < Settings | null > ;
$getMergedSettings (
defaultKey : string ,
accountDid? : string ,
@ -1765,10 +1740,7 @@ declare module "@vue/runtime-core" {
sql : string ,
params? : unknown [ ] ,
) : Promise < unknown [ ] | undefined > ;
$getSettings (
key : string ,
defaults? : Settings | null ,
) : Promise < Settings | null > ;
$getMasterSettings ( defaults? : Settings | null ) : Promise < Settings | null > ;
$getMergedSettings (
key : string ,
did? : string ,