@@ -411,26 +411,26 @@ export default (sbp('sbp/selectors/register', {
411411 }
412412
413413 try {
414- if ( ! state ) {
414+ await sbp ( 'gi.db/settings/save' , SETTING_CURRENT_USER , identityContractID )
415+ sbp ( 'okTurtles.events/emit' , LOGIN , { identityContractID, encryptionParams, state } )
416+
417+ try {
418+ if ( ! state ) {
415419 // Make sure we don't unsubscribe from our own identity contract
416420 // Note that this should be done _after_ calling
417421 // `chelonia/storeSecretKeys`: If the following line results in
418422 // syncing the identity contract and fetching events, the secret keys
419423 // for processing them will not be available otherwise.
420- await sbp ( 'chelonia/contract/retain' , identityContractID )
421- } else {
424+ await sbp ( 'chelonia/contract/retain' , identityContractID )
425+ } else {
422426 // If there is a state, we've already retained the identity contract
423427 // but might need to fetch the latest events
424- await sbp ( 'chelonia/contract/sync' , identityContractID )
428+ await sbp ( 'chelonia/contract/sync' , identityContractID )
429+ }
430+ } catch ( e ) {
431+ console . error ( '[gi.actions/identity] Error during login contract sync' , e )
432+ throw new GIErrorUIRuntimeError ( L ( 'Error during login contract sync' ) , { cause : e } )
425433 }
426- } catch ( e ) {
427- console . error ( '[gi.actions/identity] Error during login contract sync' , e )
428- throw new GIErrorUIRuntimeError ( L ( 'Error during login contract sync' ) , { cause : e } )
429- }
430-
431- try {
432- await sbp ( 'gi.db/settings/save' , SETTING_CURRENT_USER , identityContractID )
433- sbp ( 'okTurtles.events/emit' , LOGIN , { identityContractID, encryptionParams, state } )
434434
435435 const contractIDs = groupContractsByType ( cheloniaState ?. contracts )
436436 await syncContractsInOrder ( contractIDs )
0 commit comments