Clean up console logging and fix platform detection issues

- Reduce migration/platform logging verbosity in development mode (~80-90% less noise)
- Fix AbsurdSQL platform check to support 'development' alongside 'web'
- Add missing WebPlatformService methods (isWorker, initSharedArrayBuffer)
- Fix Electron API endpoint resolution to prevent JSON parsing errors
- Prevent circular database logging that caused [DB-PREVENTED-INFO] spam

Console now shows only essential information while preserving all errors/warnings
This commit is contained in:
Matthew Raymer
2025-07-03 06:31:43 +00:00
parent 292aceee75
commit b377667207
8 changed files with 162 additions and 46 deletions

View File

@@ -557,6 +557,10 @@ export default class HomeView extends Vue {
// Update component state
this.apiServer = settings.apiServer || "";
// **CRITICAL**: Ensure correct API server for platform
await this.ensureCorrectApiServer();
this.activeDid = settings.activeDid || "";
// Load contacts with graceful fallback
@@ -676,6 +680,22 @@ export default class HomeView extends Vue {
}
}
/**
* Ensures API server is correctly set for the current platform
* For Electron, always use production endpoint regardless of saved settings
*
* @internal
* Called after loading settings to ensure correct API endpoint
*/
private async ensureCorrectApiServer() {
if (process.env.VITE_PLATFORM === "electron") {
// **CRITICAL FIX**: Always use production API server for Electron
// This prevents the capacitor-electron:// protocol from being used for API calls
const { DEFAULT_ENDORSER_API_SERVER } = await import("../constants/app");
this.apiServer = DEFAULT_ENDORSER_API_SERVER;
}
}
/**
* Loads user settings from storage using ultra-concise mixin utilities
* Sets component state for:
@@ -696,6 +716,10 @@ export default class HomeView extends Vue {
});
this.apiServer = settings.apiServer || "";
// **CRITICAL**: Ensure correct API server for platform
await this.ensureCorrectApiServer();
this.activeDid = settings.activeDid || "";
this.feedLastViewedClaimId = settings.lastViewedClaimId;
this.givenName = settings.firstName || "";
@@ -934,13 +958,15 @@ export default class HomeView extends Vue {
}
/**
* Updates feed with latest activity
* Updates feed data from endorser service with error handling
* - Retrieves new gives from API
* - Processes records through filters
* - Updates last viewed claim ID
* - Handles paging if needed
*
* @internal
* @callGraph
* Called by:
* - loadMoreGives()
* - initializeIdentity()
* Called by: loadFeedData(), manual refresh
* Calls:
* - retrieveGives()
* - processFeedResults()
@@ -948,12 +974,10 @@ export default class HomeView extends Vue {
* - handleFeedError()
*
* @chain
* loadMoreGives() -> updateAllFeed()
* initializeIdentity() -> updateAllFeed()
* loadFeedData() -> updateAllFeed() -> retrieveGives()
*
* @requires
* - this.apiServer
* - this.activeDid
* - this.feedPreviousOldestId
*
* @modifies
@@ -1350,13 +1374,28 @@ export default class HomeView extends Vue {
}
/**
* Retrieve claims in reverse chronological order
* Retrieves gift data from endorser API with error handling
* - Fetches gives from API endpoint
* - Handles authentication headers
* - Processes API response with comprehensive error handling
*
* @public
* @callGraph
* Called by: updateAllFeed()
* Calls:
* - getHeaders()
* - fetch()
*
* @chain
* updateAllFeed() -> retrieveGives() -> getHeaders()
*
* @requires
* - this.activeDid
* - this.$notify
*
* @internal
* Called by updateAllFeed()
* @param endorserApiServer API server URL
* @param beforeId OptioCalled by updateAllFeed()nal ID to fetch earlier results
* @returns claims in reverse chronological order
* @param beforeId Optional ID for pagination
* @returns Promise resolving to API response data
*/
async retrieveGives(endorserApiServer: string, beforeId?: string) {
const beforeQuery = beforeId == null ? "" : "&beforeId=" + beforeId;
@@ -1365,6 +1404,7 @@ export default class HomeView extends Vue {
this.activeDid,
doNotShowErrorAgain ? undefined : this.$notify,
);
// retrieve headers for this user, but if an error happens then report it but proceed with the fetch with no header
const response = await fetch(
endorserApiServer +
@@ -1380,7 +1420,8 @@ export default class HomeView extends Vue {
throw await response.text();
}
const results = await response.json();
const responseText = await response.text();
const results = JSON.parse(responseText);
if (results.data) {
return results;