diff --git a/src/components/Splash/SplashRoot.tsx b/src/components/Splash/SplashRoot.tsx index dad9a6ff5bf431b04542cc825a28858be272a642..a4c7e2f6470b64ee8c15a39ff4f09189410c2411 100644 --- a/src/components/Splash/SplashRoot.tsx +++ b/src/components/Splash/SplashRoot.tsx @@ -228,8 +228,7 @@ const SplashRoot = ({ fadeTimer = 1000, children }: SplashRootProps) => { initializationService.initChallengeEntity(profile.explorationHash), initializationService.initAnalysis(profile), ]) - const updatedProfile: Profile = { - ...profile, + const updatedProfile: Partial<Profile> = { duelHash, quizHash, challengeHash, diff --git a/src/services/initialization.service.ts b/src/services/initialization.service.ts index 9a4634559c558bc32d9dc1f07719c2f02d57a335..56b3b9fc63ed91580768ce9ee827b6220868301c 100644 --- a/src/services/initialization.service.ts +++ b/src/services/initialization.service.ts @@ -657,10 +657,6 @@ export default class InitializationService { } public async initConsent(): Promise<TermsStatus> { - const termsStatus: TermsStatus = { - accepted: false, - versionType: 'init', - } const startTime = performance.now() try { this._setInitStep(InitSteps.CONSENT) @@ -668,39 +664,31 @@ export default class InitializationService { const isUpToDate = await termService.isConsentVersionUpToDate() const lastTerm = await termService.getLastTerm() - if (lastTerm) { - if (isUpToDate) { - const isLastConsentValidated = await termService.isLastTermValidated() - if (isLastConsentValidated) { - termsStatus.accepted = true - termsStatus.versionType = 'init' - logApp.info( - '[Initialization] Last Consent successfully loaded and valid' - ) - } else { - termsStatus.versionType = 'init' - termsStatus.accepted = false - logApp.info('[Initialization] Consent not up-to-date') - } - } else { - const versionType = await termService.getTermsVersionType() - if (versionType === 'minor') { - termsStatus.accepted = false - termsStatus.versionType = 'minor' - logApp.info('[Initialization] Minor Terms update detected') - } else { - termsStatus.accepted = false - termsStatus.versionType = 'major' - logApp.info('[Initialization] Major Terms update detected') - } - } - } else { - termsStatus.accepted = false - termsStatus.versionType = 'init' + if (!lastTerm) { logApp.info('[Initialization] Init first terms') + return { accepted: false, versionType: 'init' } + } + + if (isUpToDate) { + const isLastConsentValidated = await termService.isLastTermValidated() + if (isLastConsentValidated) { + logApp.info( + '[Initialization] Last Consent successfully loaded and valid' + ) + return { accepted: true, versionType: 'init' } + } + logApp.info('[Initialization] Consent not up-to-date') + return { accepted: false, versionType: 'init' } + } + + const versionType = await termService.getTermsVersionType() + if (versionType === 'minor') { + logApp.info('[Initialization] Minor Terms update detected') + return { accepted: false, versionType: 'minor' } } - return termsStatus + logApp.info('[Initialization] Major Terms update detected') + return { accepted: false, versionType: 'major' } } catch (error) { this._setInitStepError(InitStepsErrors.CONSENT_ERROR) const errorMessage = `Initialization error - initConsent: ${JSON.stringify(