Fix types

This commit is contained in:
Adria Navarro 2024-12-20 11:10:06 +01:00
parent dd29dcedc8
commit e00002757e
1 changed files with 17 additions and 14 deletions

View File

@ -11,7 +11,7 @@ interface BuilderViewV2Store {
interface DerivedViewV2Store extends BuilderViewV2Store {
list: ViewV2[]
selected: ViewV2
selected?: ViewV2
}
export class ViewV2Store extends DerivedBudiStore<
@ -20,20 +20,23 @@ export class ViewV2Store extends DerivedBudiStore<
> {
constructor() {
const makeDerivedStore = (store: Writable<BuilderViewV2Store>) => {
return derived([store, tables], ([$store, $tables]) => {
let list: ViewV2[] = []
$tables.list?.forEach(table => {
const views = Object.values(table?.views || {}).filter(
helpers.views.isV2
)
list = list.concat(views)
})
return {
...$store,
list,
selected: list.find(view => view.id === $store.selectedViewId),
return derived(
[store, tables],
([$store, $tables]): DerivedViewV2Store => {
let list: ViewV2[] = []
$tables.list?.forEach(table => {
const views = Object.values(table?.views || {}).filter(
helpers.views.isV2
)
list = list.concat(views)
})
return {
...$store,
list,
selected: list.find(view => view.id === $store.selectedViewId),
}
}
})
)
}
super(