From 3f80c02038d05f24ec3256407a96cdfdbe0088f3 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 30 Sep 2022 12:31:16 +0100 Subject: [PATCH] Fetch environment info early in the client app initialisation process --- packages/client/src/index.js | 13 +++++++++++-- packages/client/src/stores/initialise.js | 2 -- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/client/src/index.js b/packages/client/src/index.js index 3d0aaa1038..0e8ab8c258 100644 --- a/packages/client/src/index.js +++ b/packages/client/src/index.js @@ -1,5 +1,11 @@ import ClientApp from "./components/ClientApp.svelte" -import { componentStore, builderStore, appStore, devToolsStore } from "./stores" +import { + componentStore, + builderStore, + appStore, + devToolsStore, + environmentStore, +} from "./stores" import loadSpectrumIcons from "@budibase/bbui/spectrum-icons-rollup.js" import { get } from "svelte/store" import { initWebsocket } from "./websocket.js" @@ -15,7 +21,7 @@ loadSpectrumIcons() let app -const loadBudibase = () => { +const loadBudibase = async () => { // Update builder store with any builder flags builderStore.set({ inBuilder: !!window["##BUDIBASE_IN_BUILDER##"], @@ -36,6 +42,9 @@ const loadBudibase = () => { // server rendered app HTML appStore.actions.setAppId(window["##BUDIBASE_APP_ID##"]) + // Fetch environment info + await environmentStore.actions.fetchEnvironment() + // Enable dev tools or not. We need to be using a dev app and not inside // the builder preview to enable them. const enableDevTools = !get(builderStore).inBuilder && get(appStore).isDevApp diff --git a/packages/client/src/stores/initialise.js b/packages/client/src/stores/initialise.js index 4ad85dfd40..1900e62ce1 100644 --- a/packages/client/src/stores/initialise.js +++ b/packages/client/src/stores/initialise.js @@ -1,9 +1,7 @@ import { routeStore } from "./routes" import { appStore } from "./app" -import { environmentStore } from "./environment" export async function initialise() { await routeStore.actions.fetchRoutes() await appStore.actions.fetchAppDefinition() - await environmentStore.actions.fetchEnvironment() }