From e00002757e9e48eaf7c14f41496b44ba31af1108 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 20 Dec 2024 11:10:06 +0100 Subject: [PATCH] Fix types --- .../builder/src/stores/builder/viewsV2.ts | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/packages/builder/src/stores/builder/viewsV2.ts b/packages/builder/src/stores/builder/viewsV2.ts index ed1bdeb008..07cb606eaf 100644 --- a/packages/builder/src/stores/builder/viewsV2.ts +++ b/packages/builder/src/stores/builder/viewsV2.ts @@ -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) => { - 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(