Skip to content
Snippets Groups Projects
Commit 4e3d75fe authored by Bastien DUMONT's avatar Bastien DUMONT :angel: Committed by Hugo NOUTS
Browse files

chore(splash screen): cleanup initialization

parent b41874f4
No related branches found
No related tags found
2 merge requests!905MEP 2.4 : intégration Ma Bulle,!895chore: cleanup initialization
...@@ -228,8 +228,7 @@ const SplashRoot = ({ fadeTimer = 1000, children }: SplashRootProps) => { ...@@ -228,8 +228,7 @@ const SplashRoot = ({ fadeTimer = 1000, children }: SplashRootProps) => {
initializationService.initChallengeEntity(profile.explorationHash), initializationService.initChallengeEntity(profile.explorationHash),
initializationService.initAnalysis(profile), initializationService.initAnalysis(profile),
]) ])
const updatedProfile: Profile = { const updatedProfile: Partial<Profile> = {
...profile,
duelHash, duelHash,
quizHash, quizHash,
challengeHash, challengeHash,
......
...@@ -657,10 +657,6 @@ export default class InitializationService { ...@@ -657,10 +657,6 @@ export default class InitializationService {
} }
public async initConsent(): Promise<TermsStatus> { public async initConsent(): Promise<TermsStatus> {
const termsStatus: TermsStatus = {
accepted: false,
versionType: 'init',
}
const startTime = performance.now() const startTime = performance.now()
try { try {
this._setInitStep(InitSteps.CONSENT) this._setInitStep(InitSteps.CONSENT)
...@@ -668,39 +664,31 @@ export default class InitializationService { ...@@ -668,39 +664,31 @@ export default class InitializationService {
const isUpToDate = await termService.isConsentVersionUpToDate() const isUpToDate = await termService.isConsentVersionUpToDate()
const lastTerm = await termService.getLastTerm() const lastTerm = await termService.getLastTerm()
if (lastTerm) { 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'
logApp.info('[Initialization] Init first terms') 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) { } catch (error) {
this._setInitStepError(InitStepsErrors.CONSENT_ERROR) this._setInitStepError(InitStepsErrors.CONSENT_ERROR)
const errorMessage = `Initialization error - initConsent: ${JSON.stringify( const errorMessage = `Initialization error - initConsent: ${JSON.stringify(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment