aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjasper <jasper92341@hotmail.com>2019-04-01 10:46:30 -0700
committerjasper <jasper92341@hotmail.com>2019-04-01 10:46:30 -0700
commit8fc10dc17741fa9713604cc8846032104edf11cb (patch)
tree19b250744e55e16bdd95cc385405295e70936605
parent0117f6af9f8ae600e613402590de4c9364806967 (diff)
Add Promise.all to send requests when loading
-rw-r--r--src/boot/after_store.js39
1 files changed, 28 insertions, 11 deletions
diff --git a/src/boot/after_store.js b/src/boot/after_store.js
index f5add8ad..8db1c39d 100644
--- a/src/boot/after_store.js
+++ b/src/boot/after_store.js
@@ -219,6 +219,15 @@ 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 afterStoreSetup = async ({ store, i18n }) => {
if (store.state.config.customTheme) {
// This is a hack to deal with async loading of config.json and themes
@@ -230,18 +239,26 @@ const afterStoreSetup = async ({ store, i18n }) => {
})
}
- const apiConfig = await getStatusnetConfig({ store })
- const staticConfig = await getStaticConfig()
- await setSettings({ store, apiConfig, staticConfig })
- await getTOS({ store })
- await getInstancePanel({ store })
- await getStaticEmoji({ store })
- await getCustomEmoji({ store })
- await getNodeInfo({ store })
-
- // Now we have the server settings and can try logging in
+ // Now we can try getting the server settings and logging in
if (store.state.oauth.token) {
- await store.dispatch('loginUser', store.state.oauth.token)
+ await Promise.all([
+ setConfig({ store }),
+ getTOS({ store }),
+ getInstancePanel({ store }),
+ getStaticEmoji({ store }),
+ getCustomEmoji({ store }),
+ getNodeInfo({ store }),
+ store.dispatch('loginUser', store.state.oauth.token)
+ ])
+ } else {
+ await Promise.all([
+ setConfig({ store }),
+ getTOS({ store }),
+ getInstancePanel({ store }),
+ getStaticEmoji({ store }),
+ getCustomEmoji({ store }),
+ getNodeInfo({ store })
+ ])
}
const router = new VueRouter({