diff options
| author | Shpuld Shpludson <shp@cock.li> | 2019-04-01 19:45:08 +0000 |
|---|---|---|
| committer | Shpuld Shpludson <shp@cock.li> | 2019-04-01 19:45:08 +0000 |
| commit | ae3b92ce85c15ea170b062286bea9f0201ed1014 (patch) | |
| tree | 64d211b7962dedb735f61e7c960f89023037bd09 /src | |
| parent | 3b38e1b8a73db2837ddac36a92c8609f0734b971 (diff) | |
| parent | 90939f198b896c0644864f65a430e44e8d3a259c (diff) | |
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
Diffstat (limited to 'src')
| -rw-r--r-- | src/boot/after_store.js | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/src/boot/after_store.js b/src/boot/after_store.js index 3138cdc4..b6d292dc 100644 --- a/src/boot/after_store.js +++ b/src/boot/after_store.js @@ -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 }) => { if (store.state.config.customTheme) { // 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 }) - 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 - if (store.state.oauth.token) { - await store.dispatch('loginUser', store.state.oauth.token) - } + // Now we can try getting the server settings and logging in + await Promise.all([ + checkOAuthToken({ store }), + setConfig({ store }), + getTOS({ store }), + getInstancePanel({ store }), + getStaticEmoji({ store }), + getCustomEmoji({ store }), + getNodeInfo({ store }) + ]) const router = new VueRouter({ mode: 'history', |
