fix: ClaimView now correctly displays User #0 registration status

Fix ClaimView component to use $accountSettings() instead of $settings() to
get the current user's registration status. This resolves the issue where
User #0 appeared unregistered in ClaimView despite having isRegistered: true
in the database.

- Changed created() method to use $accountSettings() for user-specific settings
- Ensures ClaimView reads correct isRegistered value for current user
- Fixes "You posted that. false" display issue for registered users
This commit is contained in:
Matthew Raymer
2025-07-27 05:03:52 +00:00
parent 820fb29021
commit 45e5b86b0a
8 changed files with 223 additions and 59 deletions

View File

@@ -209,8 +209,8 @@ export const PlatformServiceMixin = {
},
/**
* Self-contained implementation of mapColumnsToValues
* Maps database query results to objects with column names as keys
* Map database columns to values with proper type conversion
* Handles boolean conversion from SQLite integers (0/1) to boolean values
*/
_mapColumnsToValues(
columns: string[],
@@ -219,7 +219,23 @@ export const PlatformServiceMixin = {
return values.map((row) => {
const obj: Record<string, unknown> = {};
columns.forEach((column, index) => {
obj[column] = row[index];
let value = row[index];
// Convert SQLite integer booleans to JavaScript booleans
if (column === 'isRegistered' || column === 'finishedOnboarding' ||
column === 'filterFeedByVisible' || column === 'filterFeedByNearby' ||
column === 'hideRegisterPromptOnNewContact' || column === 'showContactGivesInline' ||
column === 'showGeneralAdvanced' || column === 'showShortcutBvc' ||
column === 'warnIfProdServer' || column === 'warnIfTestServer') {
if (value === 1) {
value = true;
} else if (value === 0) {
value = false;
}
// Keep null values as null
}
obj[column] = value;
});
return obj;
});
@@ -900,23 +916,14 @@ export const PlatformServiceMixin = {
},
/**
* Maps an array of column names to an array of value arrays, creating objects where each column name
* is mapped to its corresponding value.
* @param columns Array of column names to use as object keys
* @param values Array of value arrays, where each inner array corresponds to one row of data
* @returns Array of objects where each object maps column names to their corresponding values
* Public method for mapping database columns to values
* Provides the same functionality as _mapColumnsToValues but as a public method
*/
$mapColumnsToValues(
columns: string[],
values: unknown[][],
): Array<Record<string, unknown>> {
return values.map((row) => {
const obj: Record<string, unknown> = {};
columns.forEach((column, index) => {
obj[column] = row[index];
});
return obj;
});
return this._mapColumnsToValues(columns, values);
},
/**
@@ -1379,6 +1386,79 @@ export const PlatformServiceMixin = {
whereParams,
);
},
/**
* Debug method to verify settings for a specific DID
* Useful for troubleshooting settings propagation issues
* @param did DID to check settings for
* @returns Promise<Settings | null> Settings object or null if not found
*/
async $debugDidSettings(did: string): Promise<Settings | null> {
try {
const result = await this.$dbQuery(
"SELECT * FROM settings WHERE accountDid = ?",
[did],
);
if (!result?.values?.length) {
logger.warn(`[PlatformServiceMixin] No settings found for DID: ${did}`);
return null;
}
const mappedResults = this._mapColumnsToValues(
result.columns,
result.values,
);
if (!mappedResults.length) {
logger.warn(`[PlatformServiceMixin] Failed to map settings for DID: ${did}`);
return null;
}
const settings = mappedResults[0] as Settings;
logger.info(`[PlatformServiceMixin] Settings for DID ${did}:`, {
firstName: settings.firstName,
isRegistered: settings.isRegistered,
activeDid: settings.activeDid,
apiServer: settings.apiServer,
});
return settings;
} catch (error) {
logger.error(`[PlatformServiceMixin] Error debugging settings for DID ${did}:`, error);
return null;
}
},
/**
* Debug method to verify merged settings for a specific DID
* Shows both default and DID-specific settings
* @param did DID to check merged settings for
* @returns Promise<void> Logs debug information
*/
async $debugMergedSettings(did: string): Promise<void> {
try {
// Get default settings
const defaultSettings = await this.$getSettings(MASTER_SETTINGS_KEY, {});
logger.info(`[PlatformServiceMixin] Default settings:`, defaultSettings);
// Get DID-specific settings
const didSettings = await this.$debugDidSettings(did);
// Get merged settings
const mergedSettings = await this.$getMergedSettings(MASTER_SETTINGS_KEY, did, defaultSettings || {});
logger.info(`[PlatformServiceMixin] Merged settings for ${did}:`, {
defaultSettings,
didSettings,
mergedSettings,
isRegistered: mergedSettings.isRegistered,
});
} catch (error) {
logger.error(`[PlatformServiceMixin] Error debugging merged settings for DID ${did}:`, error);
}
},
},
};
@@ -1477,6 +1557,10 @@ export interface IPlatformServiceMixin {
columns: string[],
values: unknown[][],
): Array<Record<string, unknown>>;
// Debug methods
$debugDidSettings(did: string): Promise<Settings | null>;
$debugMergedSettings(did: string): Promise<void>;
}
// TypeScript declaration merging to eliminate (this as any) type assertions
@@ -1612,5 +1696,9 @@ declare module "@vue/runtime-core" {
columns: string[],
values: unknown[][],
): Array<Record<string, unknown>>;
// Debug methods
$debugDidSettings(did: string): Promise<Settings | null>;
$debugMergedSettings(did: string): Promise<void>;
}
}