diff --git a/src/utils/PlatformServiceMixin.ts b/src/utils/PlatformServiceMixin.ts index c36ede9a..010d79ec 100644 --- a/src/utils/PlatformServiceMixin.ts +++ b/src/utils/PlatformServiceMixin.ts @@ -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 { 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], - ); - } + // Master settings: query by id + 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 { 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 { - const settings = await this.$getSettings(MASTER_SETTINGS_KEY, defaults); + const settings = await this.$getMasterSettings(defaults); if (!settings) { return defaults; @@ -802,10 +786,7 @@ export const PlatformServiceMixin = { ): Promise { 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 { 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; $dbExec(sql: string, params?: unknown[]): Promise; $dbGetOneRow(sql: string, params?: unknown[]): Promise; - $getSettings( - key: string, - fallback?: Settings | null, - ): Promise; + $getMasterSettings(fallback?: Settings | null): Promise; $getMergedSettings( defaultKey: string, accountDid?: string, @@ -1765,10 +1740,7 @@ declare module "@vue/runtime-core" { sql: string, params?: unknown[], ): Promise; - $getSettings( - key: string, - defaults?: Settings | null, - ): Promise; + $getMasterSettings(defaults?: Settings | null): Promise; $getMergedSettings( key: string, did?: string, diff --git a/src/views/ContactAmountsView.vue b/src/views/ContactAmountsView.vue index 233ddbce..56ee2061 100644 --- a/src/views/ContactAmountsView.vue +++ b/src/views/ContactAmountsView.vue @@ -124,7 +124,7 @@ import { NOTIFY_CONFIRMATION_RESTRICTION, } from "../constants/notifications"; import { Contact } from "../db/tables/contacts"; -import { MASTER_SETTINGS_KEY } from "../db/tables/settings"; + import { GiveSummaryRecord, GiveActionClaim } from "../interfaces"; import { AgreeActionClaim } from "../interfaces/claims"; import { @@ -223,7 +223,7 @@ export default class ContactAmountssView extends Vue { const contact = await this.$getContact(contactDid); this.contact = contact; - const settings = await this.$getSettings(MASTER_SETTINGS_KEY); + const settings = await this.$getMasterSettings(); this.activeDid = settings?.activeDid || ""; this.apiServer = settings?.apiServer || "";