revert derivedstore implementation
This commit is contained in:
parent
2f1b7811c3
commit
4ee99f807c
|
@ -1,3 +1,4 @@
|
|||
import { get } from "svelte/store"
|
||||
import { API } from "@/api"
|
||||
import { GetUserFlagsResponse } from "@budibase/types"
|
||||
import { BudiStore } from "../BudiStore"
|
||||
|
|
|
@ -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)
|
||||
})
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
Loading…
Reference in New Issue