TT#129212 Optimise the initial load of the user

TAC:
Parallelise requests in the user load function which do not depend on each other

Note: it can be optimized better if we lazyload RTCengine and initialize it in a lazy way. But it should be implemented as a separate ticket.

Change-Id: I911cd29b880ab8027b341d7953c6c8337390e19b
mr10.0
Sergii Leonenko 4 years ago committed by Hans-Peter Herzog
parent 0354615428
commit 5a3093e837

@ -39,13 +39,15 @@ export function getUserData (id) {
getSubscriberById(id), getSubscriberById(id),
getCapabilities(id), getCapabilities(id),
getFaxServerSettings(id), getFaxServerSettings(id),
getResellerBranding() getResellerBranding(),
]).then((results) => { getPlatformInfo()
results[1].faxactive = results[2].active ]).then(([subscriber, capabilities, faxServerSettings, resellerBranding, platformInfo]) => {
capabilities.faxactive = faxServerSettings.active
resolve({ resolve({
subscriber: results[0], subscriber,
capabilities: results[1], capabilities,
resellerBranding: results[3]?.items[0] || null resellerBranding: resellerBranding?.items[0] || null,
platformInfo
}) })
}).catch((err) => { }).catch((err) => {
reject(err) reject(err)
@ -137,6 +139,12 @@ export async function getResellerBranding () {
}) })
} }
export async function getPlatformInfo () {
return get({
path: 'api/platforminfo'
})
}
export async function createAuthToken (tokenExpiringTime) { export async function createAuthToken (tokenExpiringTime) {
const response = await post({ const response = await post({
resource: 'authtokens', resource: 'authtokens',

@ -24,7 +24,6 @@ import {
} from '../api/subscriber' } from '../api/subscriber'
import { deleteJwt, getJwt, getSubscriberId, setJwt, setSubscriberId } from 'src/auth' import { deleteJwt, getJwt, getSubscriberId, setJwt, setSubscriberId } from 'src/auth'
import { setSession } from 'src/storage' import { setSession } from 'src/storage'
import { get } from 'src/api/common'
import QRCode from 'qrcode' import QRCode from 'qrcode'
import { import {
qrPayload qrPayload
@ -236,6 +235,7 @@ export default {
state.subscriber = options.subscriber state.subscriber = options.subscriber
state.capabilities = options.capabilities state.capabilities = options.capabilities
state.resellerBranding = options.resellerBranding state.resellerBranding = options.resellerBranding
state.platformInfo = options.platformInfo
state.userDataSucceeded = true state.userDataSucceeded = true
state.userDataRequesting = false state.userDataRequesting = false
@ -318,9 +318,6 @@ export default {
setProfile (state, value) { setProfile (state, value) {
state.profile = value state.profile = value
}, },
platformInfo (state, payload) {
state.platformInfo = payload
},
setQrCode (state, qrCode) { setQrCode (state, qrCode) {
state.qrCode = qrCode state.qrCode = qrCode
}, },
@ -373,9 +370,6 @@ export default {
const profile = await getSubscriberProfile(userData.subscriber.profile_id) const profile = await getSubscriberProfile(userData.subscriber.profile_id)
context.commit('setProfile', profile) context.commit('setProfile', profile)
} }
context.commit('platformInfo', await get({
path: 'api/platforminfo'
}))
await context.dispatch('forwardHome') await context.dispatch('forwardHome')
} catch (err) { } catch (err) {
console.debug(err) console.debug(err)

Loading…
Cancel
Save