Merge branch 'fix/sending-requests-when-loading' into 'develop'
#463 Add Promise.all to send requests when loading Closes #463 See merge request pleroma/pleroma-fe!723
This commit is contained in:
commit
ae3b92ce85
|
@ -219,6 +219,28 @@ const getNodeInfo = async ({ store }) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const setConfig = async ({ store }) => {
|
||||||
|
// apiConfig, staticConfig
|
||||||
|
const configInfos = await Promise.all([getStatusnetConfig({ store }), getStaticConfig()])
|
||||||
|
const apiConfig = configInfos[0]
|
||||||
|
const staticConfig = configInfos[1]
|
||||||
|
|
||||||
|
await setSettings({ store, apiConfig, staticConfig })
|
||||||
|
}
|
||||||
|
|
||||||
|
const checkOAuthToken = async ({ store }) => {
|
||||||
|
return new Promise(async (resolve, reject) => {
|
||||||
|
if (store.state.oauth.token) {
|
||||||
|
try {
|
||||||
|
await store.dispatch('loginUser', store.state.oauth.token)
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const afterStoreSetup = async ({ store, i18n }) => {
|
const afterStoreSetup = async ({ store, i18n }) => {
|
||||||
if (store.state.config.customTheme) {
|
if (store.state.config.customTheme) {
|
||||||
// This is a hack to deal with async loading of config.json and themes
|
// This is a hack to deal with async loading of config.json and themes
|
||||||
|
@ -230,19 +252,16 @@ const afterStoreSetup = async ({ store, i18n }) => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const apiConfig = await getStatusnetConfig({ store })
|
// Now we can try getting the server settings and logging in
|
||||||
const staticConfig = await getStaticConfig()
|
await Promise.all([
|
||||||
await setSettings({ store, apiConfig, staticConfig })
|
checkOAuthToken({ store }),
|
||||||
await getTOS({ store })
|
setConfig({ store }),
|
||||||
await getInstancePanel({ store })
|
getTOS({ store }),
|
||||||
await getStaticEmoji({ store })
|
getInstancePanel({ store }),
|
||||||
await getCustomEmoji({ store })
|
getStaticEmoji({ store }),
|
||||||
await getNodeInfo({ store })
|
getCustomEmoji({ store }),
|
||||||
|
getNodeInfo({ store })
|
||||||
// Now we have the server settings and can try logging in
|
])
|
||||||
if (store.state.oauth.token) {
|
|
||||||
await store.dispatch('loginUser', store.state.oauth.token)
|
|
||||||
}
|
|
||||||
|
|
||||||
const router = new VueRouter({
|
const router = new VueRouter({
|
||||||
mode: 'history',
|
mode: 'history',
|
||||||
|
|
Loading…
Reference in New Issue