@ -557,6 +557,10 @@ export default class HomeView extends Vue {
/ / U p d a t e c o m p o n e n t s t a t e
/ / U p d a t e c o m p o n e n t s t a t e
this . apiServer = settings . apiServer || "" ;
this . apiServer = settings . apiServer || "" ;
/ / * * C R I T I C A L * * : E n s u r e c o r r e c t A P I s e r v e r f o r p l a t f o r m
await this . ensureCorrectApiServer ( ) ;
this . activeDid = settings . activeDid || "" ;
this . activeDid = settings . activeDid || "" ;
/ / L o a d c o n t a c t s w i t h g r a c e f u l f a l l b a c k
/ / L o a d c o n t a c t s w i t h g r a c e f u l f a l l b a c k
@ -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" ) {
/ / * * C R I T I C A L F I X * * : A l w a y s u s e p r o d u c t i o n A P I s e r v e r f o r E l e c t r o n
/ / T h i s p r e v e n t s t h e c a p a c i t o r - e l e c t r o n : / / p r o t o c o l f r o m b e i n g u s e d f o r A P I c a l l s
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
* Loads user settings from storage using ultra - concise mixin utilities
* Sets component state for :
* Sets component state for :
@ -696,6 +716,10 @@ export default class HomeView extends Vue {
} ) ;
} ) ;
this . apiServer = settings . apiServer || "" ;
this . apiServer = settings . apiServer || "" ;
/ / * * C R I T I C A L * * : E n s u r e c o r r e c t A P I s e r v e r f o r p l a t f o r m
await this . ensureCorrectApiServer ( ) ;
this . activeDid = settings . activeDid || "" ;
this . activeDid = settings . activeDid || "" ;
this . feedLastViewedClaimId = settings . lastViewedClaimId ;
this . feedLastViewedClaimId = settings . lastViewedClaimId ;
this . givenName = settings . firstName || "" ;
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
* @ internal
* @ callGraph
* @ callGraph
* Called by :
* Called by : loadFeedData ( ) , manual refresh
* - loadMoreGives ( )
* - initializeIdentity ( )
* Calls :
* Calls :
* - retrieveGives ( )
* - retrieveGives ( )
* - processFeedResults ( )
* - processFeedResults ( )
@ -948,12 +974,10 @@ export default class HomeView extends Vue {
* - handleFeedError ( )
* - handleFeedError ( )
*
*
* @ chain
* @ chain
* loadMoreGives ( ) - > updateAllFeed ( )
* loadFeedData ( ) - > updateAllFeed ( ) - > retrieveGives ( )
* initializeIdentity ( ) - > updateAllFeed ( )
*
*
* @ requires
* @ requires
* - this . apiServer
* - this . apiServer
* - this . activeDid
* - this . feedPreviousOldestId
* - this . feedPreviousOldestId
*
*
* @ modifies
* @ 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 endorserApiServer API server URL
* @ param beforeId OptioCalled by updateAllFeed ( ) nal ID to fetch earlier results
* @ param beforeId Optional ID for pagination
* @ returns claims in reverse chronological order
* @ returns Promise resolving to API response data
* /
* /
async retrieveGives ( endorserApiServer : string , beforeId ? : string ) {
async retrieveGives ( endorserApiServer : string , beforeId ? : string ) {
const beforeQuery = beforeId == null ? "" : "&beforeId=" + beforeId ;
const beforeQuery = beforeId == null ? "" : "&beforeId=" + beforeId ;
@ -1365,6 +1404,7 @@ export default class HomeView extends Vue {
this . activeDid ,
this . activeDid ,
doNotShowErrorAgain ? undefined : this . $notify ,
doNotShowErrorAgain ? undefined : this . $notify ,
) ;
) ;
/ / r e t r i e v e h e a d e r s f o r t h i s u s e r , b u t i f a n e r r o r h a p p e n s t h e n r e p o r t i t b u t p r o c e e d w i t h t h e f e t c h w i t h n o h e a d e r
/ / r e t r i e v e h e a d e r s f o r t h i s u s e r , b u t i f a n e r r o r h a p p e n s t h e n r e p o r t i t b u t p r o c e e d w i t h t h e f e t c h w i t h n o h e a d e r
const response = await fetch (
const response = await fetch (
endorserApiServer +
endorserApiServer +
@ -1380,7 +1420,8 @@ export default class HomeView extends Vue {
throw await response . text ( ) ;
throw await response . text ( ) ;
}
}
const results = await response . json ( ) ;
const responseText = await response . text ( ) ;
const results = JSON . parse ( responseText ) ;
if ( results . data ) {
if ( results . data ) {
return results ;
return results ;