Fetch environment info early in the client app initialisation process

This commit is contained in:
Andrew Kingston 2022-09-30 12:31:16 +01:00
parent c02e67f6c2
commit 3f80c02038
2 changed files with 11 additions and 4 deletions

View File

@ -1,5 +1,11 @@
import ClientApp from "./components/ClientApp.svelte" 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 loadSpectrumIcons from "@budibase/bbui/spectrum-icons-rollup.js"
import { get } from "svelte/store" import { get } from "svelte/store"
import { initWebsocket } from "./websocket.js" import { initWebsocket } from "./websocket.js"
@ -15,7 +21,7 @@ loadSpectrumIcons()
let app let app
const loadBudibase = () => { const loadBudibase = async () => {
// Update builder store with any builder flags // Update builder store with any builder flags
builderStore.set({ builderStore.set({
inBuilder: !!window["##BUDIBASE_IN_BUILDER##"], inBuilder: !!window["##BUDIBASE_IN_BUILDER##"],
@ -36,6 +42,9 @@ const loadBudibase = () => {
// server rendered app HTML // server rendered app HTML
appStore.actions.setAppId(window["##BUDIBASE_APP_ID##"]) 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 // Enable dev tools or not. We need to be using a dev app and not inside
// the builder preview to enable them. // the builder preview to enable them.
const enableDevTools = !get(builderStore).inBuilder && get(appStore).isDevApp const enableDevTools = !get(builderStore).inBuilder && get(appStore).isDevApp

View File

@ -1,9 +1,7 @@
import { routeStore } from "./routes" import { routeStore } from "./routes"
import { appStore } from "./app" import { appStore } from "./app"
import { environmentStore } from "./environment"
export async function initialise() { export async function initialise() {
await routeStore.actions.fetchRoutes() await routeStore.actions.fetchRoutes()
await appStore.actions.fetchAppDefinition() await appStore.actions.fetchAppDefinition()
await environmentStore.actions.fetchEnvironment()
} }