revert derivedstore implementation

This commit is contained in:
Peter Clement 2025-01-02 12:22:46 +00:00
parent 2f1b7811c3
commit 4ee99f807c
3 changed files with 6 additions and 27 deletions

View File

@ -1,3 +1,4 @@
import { get } from "svelte/store"
import { API } from "@/api"
import { GetUserFlagsResponse } from "@budibase/types"
import { BudiStore } from "../BudiStore"

View File

@ -1,7 +1,7 @@
import { derived, get } from "svelte/store"
import { componentStore } from "@/stores/builder"
import { API } from "@/api"
import { BudiStore, DerivedBudiStore } from "../BudiStore"
import { BudiStore } from "../BudiStore"
import { Layout } from "@budibase/types"
interface LayoutState {
@ -9,10 +9,6 @@ interface LayoutState {
selectedLayoutId: string | null
}
interface DerivedLayoutState extends LayoutState {
selectedLayout: Layout | null
}
export const INITIAL_LAYOUT_STATE: LayoutState = {
layouts: [],
selectedLayoutId: null,
@ -79,24 +75,6 @@ export class LayoutStore extends BudiStore<LayoutState> {
export const layoutStore = new LayoutStore()
export class SelectedLayoutStore extends DerivedBudiStore<
LayoutState,
DerivedLayoutState
> {
constructor(layoutStore: LayoutStore) {
const makeDerivedStore = () => {
return derived(layoutStore, $store => {
return {
...$store,
selectedLayout:
$store.layouts?.find(
layout => layout._id === $store.selectedLayoutId
) || null,
}
})
}
super(INITIAL_LAYOUT_STATE, makeDerivedStore)
}
}
export const selectedLayout = new SelectedLayoutStore(layoutStore)
export const selectedLayout = derived(layoutStore, $store => {
return $store.layouts?.find(layout => layout._id === $store.selectedLayoutId)
})

View File

@ -1,7 +1,7 @@
import { get } from "svelte/store"
import { BudiStore } from "../BudiStore"
import { PreviewDevice } from "@budibase/types"
type PreviewDevice = "desktop" | "tablet" | "mobile"
type PreviewEventHandler = (name: string, payload?: any) => void
type ComponentContext = Record<string, any>