Pull derived selected screen store out of main screen store

This commit is contained in:
Andrew Kingston 2024-02-05 11:24:34 +00:00
parent 1650f37329
commit b04d92f8b2
1 changed files with 3 additions and 7 deletions

View File

@ -39,12 +39,6 @@ export class ScreenStore extends BudiStore {
this.sequentialScreenPatch = this.sequentialScreenPatch.bind(this) this.sequentialScreenPatch = this.sequentialScreenPatch.bind(this)
this.removeCustomLayout = this.removeCustomLayout.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({ this.history = createHistoryStore({
getDoc: id => get(this.store).screens?.find(screen => screen._id === id), getDoc: id => get(this.store).screens?.find(screen => screen._id === id),
selectDoc: this.select, selectDoc: this.select,
@ -485,7 +479,9 @@ export class ScreenStore extends BudiStore {
export const screenStore = new ScreenStore() 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 export const currentAsset = selectedScreen