From b04d92f8b27ec565602d7e0f8dbfe7a27fb02de7 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 5 Feb 2024 11:24:34 +0000 Subject: [PATCH] Pull derived selected screen store out of main screen store --- packages/builder/src/stores/builder/screens.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/builder/src/stores/builder/screens.js b/packages/builder/src/stores/builder/screens.js index 7afa1d3136..b1aaa26b45 100644 --- a/packages/builder/src/stores/builder/screens.js +++ b/packages/builder/src/stores/builder/screens.js @@ -39,12 +39,6 @@ export class ScreenStore extends BudiStore { this.sequentialScreenPatch = this.sequentialScreenPatch.bind(this) this.removeCustomLayout = this.removeCustomLayout.bind(this) - this.selected = derived(this.store, $store => { - return get(this.store).screens.find( - screen => screen._id === $store.selectedScreenId - ) - }) - this.history = createHistoryStore({ getDoc: id => get(this.store).screens?.find(screen => screen._id === id), selectDoc: this.select, @@ -485,7 +479,9 @@ export class ScreenStore extends BudiStore { export const screenStore = new ScreenStore() -export const selectedScreen = screenStore.selected +export const selectedScreen = derived(screenStore, $store => { + return $store.screens.find(screen => screen._id === $store.selectedScreenId) +}) export const currentAsset = selectedScreen