From 986069d7d7b9167c3155b5b2f4bd66b56afefb69 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 2 Oct 2023 08:19:59 +0100 Subject: [PATCH] Fix issue causing client apps to initialise 3 times --- .../client/src/components/devtools/DevToolsHeader.svelte | 1 - packages/client/src/stores/devTools.js | 9 ++++++++- packages/client/src/stores/initialise.js | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/client/src/components/devtools/DevToolsHeader.svelte b/packages/client/src/components/devtools/DevToolsHeader.svelte index a15e8351a5..55b705e717 100644 --- a/packages/client/src/components/devtools/DevToolsHeader.svelte +++ b/packages/client/src/components/devtools/DevToolsHeader.svelte @@ -25,7 +25,6 @@ value: roleId, }) } - devToolsStore.actions.changeRole(SELF_ROLE) return list } diff --git a/packages/client/src/stores/devTools.js b/packages/client/src/stores/devTools.js index 32f3c8e617..db9b9e10b4 100644 --- a/packages/client/src/stores/devTools.js +++ b/packages/client/src/stores/devTools.js @@ -2,6 +2,7 @@ import { createLocalStorageStore } from "@budibase/frontend-core" import { initialise } from "./initialise" import { authStore } from "./auth" import { API } from "../api" +import { get } from "svelte/store" const initialState = { visible: false, @@ -27,9 +28,15 @@ const createDevToolStore = () => { } const changeRole = async role => { + if (role === "self") { + role = null + } + if (role === get(store).role) { + return + } store.update(state => ({ ...state, - role: role === "self" ? null : role, + role, })) API.invalidateCache() await authStore.actions.fetchUser() diff --git a/packages/client/src/stores/initialise.js b/packages/client/src/stores/initialise.js index f34d775a4e..86c761367c 100644 --- a/packages/client/src/stores/initialise.js +++ b/packages/client/src/stores/initialise.js @@ -3,6 +3,7 @@ import { appStore } from "./app" import { orgStore } from "./org" export async function initialise() { + console.log("initialise!") await routeStore.actions.fetchRoutes() await appStore.actions.fetchAppDefinition() await orgStore.actions.init()