Browse Source

Remove databaseUtil dependency from PlatformServiceMixin

- Replace $accountSettings method's databaseUtil import with self-contained implementation
- Use existing $getMergedSettings method instead of retrieveSettingsForActiveAccount
- Maintain all functionality including Electron-specific API server fixes
- Eliminate circular dependency between PlatformServiceMixin and databaseUtil
- Fix linting issues with proper formatting and trailing commas
- PlatformServiceMixin now completely independent for migration process
web-serve-fix
Matthew Raymer 2 weeks ago
parent
commit
74a8365a14
  1. 52
      src/utils/PlatformServiceMixin.ts

52
src/utils/PlatformServiceMixin.ts

@ -617,19 +617,51 @@ export const PlatformServiceMixin = {
did?: string, did?: string,
defaults: Settings = {}, defaults: Settings = {},
): Promise<Settings> { ): Promise<Settings> {
// Import the working retrieveSettingsForActiveAccount function
const { retrieveSettingsForActiveAccount } = await import(
"@/db/databaseUtil"
);
try { try {
// Use the working function that properly merges settings // Get default settings first
const settings = await retrieveSettingsForActiveAccount(); const defaultSettings = await this.$getSettings(
MASTER_SETTINGS_KEY,
defaults,
);
// Merge with any provided defaults if (!defaultSettings) {
const mergedSettings = { ...defaults, ...settings }; return defaults;
}
return mergedSettings; // Determine which DID to use
const targetDid = did || defaultSettings.activeDid;
// If no target DID, return default settings
if (!targetDid) {
return defaultSettings;
}
// Get merged settings using existing method
const mergedSettings = await this.$getMergedSettings(
MASTER_SETTINGS_KEY,
targetDid,
defaultSettings,
);
// **ELECTRON-SPECIFIC FIX**: Force production API endpoints for Electron
// This ensures Electron doesn't use localhost development servers that might be saved in user settings
if (process.env.VITE_PLATFORM === "electron") {
// Import constants dynamically to get platform-specific values
const { DEFAULT_ENDORSER_API_SERVER } = await import(
"../constants/app"
);
mergedSettings.apiServer = DEFAULT_ENDORSER_API_SERVER;
logger.debug(
`[Electron Settings] Forced API server to: ${DEFAULT_ENDORSER_API_SERVER}`,
);
}
// Merge with any provided defaults (these take highest precedence)
const finalSettings = { ...mergedSettings, ...defaults };
return finalSettings;
} catch (error) { } catch (error) {
logger.error( logger.error(
"[PlatformServiceMixin] Error in $accountSettings:", "[PlatformServiceMixin] Error in $accountSettings:",

Loading…
Cancel
Save