Updated the Messages to the new abstracted composite syntax.

This commit is contained in:
Samuel Andert
2023-07-26 16:25:59 +02:00
parent 920e7b7ca1
commit 979251bd6b
15 changed files with 220 additions and 161 deletions

View File

@ -1,5 +1,5 @@
<script lang="ts">
import { onDestroy, onMount } from 'svelte';
import { onDestroy } from 'svelte';
import Composite from './Composite.svelte';
import components from '$lib/core/componentLoader';
import services from '$lib/core/servicesLoader';
@ -66,9 +66,19 @@
if (externalID === 'data') {
const unsubscribe = dataStore.subscribe((store) => {
if (externalKey in store) {
localStore.update((storeValue) => {
return { ...storeValue, [localKey]: store[externalKey] };
});
// Check if the data item is a Svelte store
if (store[externalKey] && typeof store[externalKey].subscribe === 'function') {
let innerUnsub = store[externalKey].subscribe((value) => {
localStore.update((storeValue) => {
return { ...storeValue, [localKey]: value };
});
});
onDestroy(innerUnsub);
} else {
localStore.update((storeValue) => {
return { ...storeValue, [localKey]: store[externalKey] };
});
}
}
});