fix: random node now works as expected

This commit is contained in:
2024-04-23 20:35:56 +02:00
parent 198a868fc6
commit 070a5b52d0
16 changed files with 141 additions and 84 deletions

View File

@ -77,7 +77,7 @@
>
{#key id && graphId}
<div class="content" class:disabled={$inputSockets?.has(socketId)}>
{#if inputType.label !== false}
{#if inputType.label !== ""}
<label for={elementId}>{input.label || id}</label>
{/if}
{#if inputType.external !== true}

View File

@ -16,11 +16,13 @@
props: Node["props"],
inputs: Record<string, NodeInput>,
) {
const store = {};
const store: Record<string, unknown> = {};
Object.keys(inputs).forEach((key) => {
store[key] = props[key] || inputs[key].value;
if (props) {
//@ts-ignore
store[key] = props[key] || inputs[key].value;
}
});
console.log({ store, props });
return writable(store);
}
@ -35,24 +37,18 @@
function updateNode() {
if (!node || !$store) return;
let needsUpdate = false;
Object.keys($store).forEach((_key: string) => {
node.props = node.props || {};
const key = _key as keyof typeof $store;
let needsUpdate = false;
console.log({ key });
if (
node &&
$store &&
key in node.props &&
node.props[key] !== $store[key]
) {
if (node && $store && node.props[key] !== $store[key]) {
needsUpdate = true;
node.props[key] = $store[key];
}
if (needsUpdate) {
manager.execute();
}
});
if (needsUpdate) {
manager.execute();
}
}
$: if (store && $store) {