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. 50
      src/utils/PlatformServiceMixin.ts

50
src/utils/PlatformServiceMixin.ts

@ -617,19 +617,51 @@ export const PlatformServiceMixin = {
did?: string,
defaults: Settings = {},
): Promise<Settings> {
// Import the working retrieveSettingsForActiveAccount function
const { retrieveSettingsForActiveAccount } = await import(
"@/db/databaseUtil"
try {
// Get default settings first
const defaultSettings = await this.$getSettings(
MASTER_SETTINGS_KEY,
defaults,
);
try {
// Use the working function that properly merges settings
const settings = await retrieveSettingsForActiveAccount();
if (!defaultSettings) {
return defaults;
}
// Merge with any provided defaults
const mergedSettings = { ...defaults, ...settings };
// Determine which DID to use
const targetDid = did || defaultSettings.activeDid;
return mergedSettings;
// 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) {
logger.error(
"[PlatformServiceMixin] Error in $accountSettings:",

Loading…
Cancel
Save