From f5197df8b46aff3d45dfa509771f7c8528e82ee7 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 4 Feb 2022 09:29:51 +0000 Subject: [PATCH] Reset the builder store whenever unmounting the app root layout --- packages/builder/src/builderStore/store/frontend.js | 3 +++ .../src/pages/builder/app/[application]/_layout.svelte | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js index 0d740e08e0..d838150efc 100644 --- a/packages/builder/src/builderStore/store/frontend.js +++ b/packages/builder/src/builderStore/store/frontend.js @@ -65,6 +65,9 @@ export const getFrontendStore = () => { const store = writable({ ...INITIAL_FRONTEND_STATE }) store.actions = { + reset: () => { + store.set({ ...INITIAL_FRONTEND_STATE }) + }, initialise: async pkg => { const { layouts, screens, application, clientLibPath } = pkg const components = await fetchComponentLibDefinitions(application.appId) diff --git a/packages/builder/src/pages/builder/app/[application]/_layout.svelte b/packages/builder/src/pages/builder/app/[application]/_layout.svelte index 0478b46f73..553125e1a7 100644 --- a/packages/builder/src/pages/builder/app/[application]/_layout.svelte +++ b/packages/builder/src/pages/builder/app/[application]/_layout.svelte @@ -12,7 +12,7 @@ import Logo from "assets/bb-emblem.svg" import { capitalise } from "helpers" import UpgradeModal from "../../../../components/upgrade/UpgradeModal.svelte" - import { onMount } from "svelte" + import { onMount, onDestroy } from "svelte" // Get Package and set store export let application @@ -81,6 +81,10 @@ hasSynced = true } }) + + onDestroy(() => { + store.actions.reset() + }) {#await promise}