Skip to content
Snippets Groups Projects
Commit a7af916b authored by Bastien DUMONT's avatar Bastien DUMONT :angel:
Browse files

Revert "feat: improve app load time"

This reverts commit 2235acc7.
parent 7ac64d20
No related branches found
No related tags found
1 merge request!1246fix: flagship app loading
......@@ -19,6 +19,7 @@ import {
PartnersInfo,
Profile,
ProfileType,
UserChallenge,
} from 'models'
import React, { ReactNode, useCallback, useEffect, useState } from 'react'
import ActionService from 'services/action.service'
......@@ -186,33 +187,27 @@ const SplashRoot = ({ fadeTimer = 1000, children }: SplashRootProps) => {
Sentry.startSpan({ name: 'Initialize app' }, async () => {
const initializationService = new InitializationService(
client,
setInitStep,
setInitStepErrors
)
const customPopupService = new CustomPopupService(client)
const partnersInfoService = new PartnersInfoService(client)
const ms = new MigrationService(client, setInitStepErrors)
try {
console.group('Initialization logs')
// Run init steps in parallel
setInitStep(InitSteps.PROFILE)
const [
termsStatus,
,
profile,
profileType,
profileEcogesture,
fluidStatus,
] = await Promise.all([
initializationService.initConsent(),
initializationService.initFluidPrices(),
initializationService.initProfile(),
initializationService.initProfileType(),
initializationService.initProfileEcogesture(),
initializationService.initFluidStatus(),
])
console.groupCollapsed('Initialization logs')
// init Terms
const termsStatus = await initializationService.initConsent()
if (subscribed) dispatch(updateTermsStatus(termsStatus))
setInitStep(InitSteps.MIGRATION)
// Init fluidPrices
await initializationService.initFluidPrices()
// Init profile and update ecogestures, challenges, analysis
const profile = await initializationService.initProfile()
const profileType = await initializationService.initProfileType()
const profileEcogesture =
await initializationService.initProfileEcogesture()
const migrationsResult = await ms.runMigrations(migrations)
// Init last release notes when they exist
dispatch(
......@@ -224,7 +219,6 @@ const SplashRoot = ({ fadeTimer = 1000, children }: SplashRootProps) => {
)
if (subscribed && profile) {
setValidExploration(UserExplorationID.EXPLORATION007)
setInitStep(InitSteps.CHALLENGES)
const [
duelHash,
quizHash,
......@@ -260,11 +254,11 @@ const SplashRoot = ({ fadeTimer = 1000, children }: SplashRootProps) => {
}
dispatch(toggleAnalysisNotification(!profile.haveSeenLastAnalysis))
}
// Process fluids status
// Init Fluid status && lastDate for the chart
const fluidStatus = await initializationService.initFluidStatus()
if (subscribed) {
dispatch(setFluidStatus(fluidStatus))
let lastDataDate = DateTime.fromISO('0001-01-01')
let lastDataDate: DateTime | null = DateTime.fromISO('0001-01-01')
for (const fluid of fluidStatus) {
if (fluid.lastDataDate && fluid.lastDataDate > lastDataDate) {
lastDataDate = fluid.lastDataDate
......@@ -292,9 +286,10 @@ const SplashRoot = ({ fadeTimer = 1000, children }: SplashRootProps) => {
UserActionState.ONGOING
) {
const actionService = new ActionService(client)
const updatedUserChallenge = await actionService.isActionDone(
filteredCurrentOngoingChallenge[0]
)
const updatedUserChallenge: UserChallenge | null =
await actionService.isActionDone(
filteredCurrentOngoingChallenge[0]
)
if (updatedUserChallenge) {
dispatch(updateUserChallengeList(updatedUserChallenge))
}
......@@ -326,7 +321,7 @@ const SplashRoot = ({ fadeTimer = 1000, children }: SplashRootProps) => {
)
// Check is duel is done and display notification
const challengeService = new ChallengeService(client)
const { isDone } = challengeService.isChallengeDone(
const { isDone } = await challengeService.isChallengeDone(
updatedUserChallenge,
dataloads
)
......
......@@ -27,7 +27,7 @@ exports[`SplashRoot component should be rendered correctly 1`] = `
>
<div
class="splash-progress-bar-content"
style="left: -90%;"
style="left: -73%;"
/>
</div>
</div>
......@@ -35,7 +35,7 @@ exports[`SplashRoot component should be rendered correctly 1`] = `
<div
class="step-label text-18-normal"
>
splashscreen.step.profile
splashscreen.step.1
</div>
<div
class="splash-logos-container"
......@@ -83,7 +83,7 @@ exports[`SplashRoot component should render the error screen 1`] = `
<div
class="splash-error-text text-18-normal"
>
splashscreen.consos_error
splashscreen.consent_error
</div>
</div>
</div>
......
......@@ -23,7 +23,7 @@ exports[`SplashScreen component should be rendered correctly 1`] = `
>
<div
class="splash-progress-bar-content"
style="left: -90%;"
style="left: -73%;"
/>
</div>
</div>
......@@ -31,7 +31,7 @@ exports[`SplashScreen component should be rendered correctly 1`] = `
<div
class="step-label text-18-normal"
>
splashscreen.step.profile
splashscreen.step.1
</div>
<div
class="splash-logos-container"
......
export enum InitSteps {
PROFILE = 'profile',
MIGRATION = 'migration',
CHALLENGES = 'challenges',
MIGRATION,
CONSENT,
PROFILE,
CHALLENGES,
PRICES, // never used
CONSOS,
}
export enum InitStepsErrors {
MIGRATION_ERROR = 'migration_error',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment