Refactored composer component interface to one single $me store

This commit is contained in:
Samuel Andert
2023-08-07 11:54:27 +02:00
parent 1a8bb64ff2
commit d36a94badc
5 changed files with 35 additions and 47 deletions

View File

@ -60,20 +60,19 @@
subscribeAndMapQueries(component.id, component.data.map);
}
}
if (component.children) {
component.children.forEach(loadComponentAndInitializeState);
}
// Load component and service
const componentName = component.component || 'FallBack';
component.me = {
getComposerStore(component.id).update((storeValue) => ({
...storeValue,
id: component.id,
do: {
core: coreServices,
machine: component.machineService || null
}
};
}));
if (component.children) {
component.children.forEach(loadComponentAndInitializeState);
}
const componentName = component.component || 'FallBack';
return await getComponent(componentName);
}
@ -128,12 +127,7 @@
style={layoutStyle}
>
{#await loadComponentAndInitializeState(composer) then Component}
<svelte:component
this={Component}
id={composer.id}
data={getComposerStore(composer.id)}
me={composer.me}
/>
<svelte:component this={Component} id={composer.id} me={getComposerStore(composer.id)} />
{/await}
{#if composer?.children}
{#each composer.children as child (child.id)}
@ -142,12 +136,7 @@
style={`grid-area: ${child.slot}`}
>
{#await loadComponentAndInitializeState(child) then ChildComponent}
<svelte:component
this={ChildComponent}
id={child.id}
data={getComposerStore(child.id)}
me={child.me}
/>
<svelte:component this={ChildComponent} id={child.id} me={getComposerStore(child.id)} />
{#if child.children && child.children.length}
<Composer composer={child} />
{/if}