Merge pull request #120 from space-nuko/previews

Minor fixes
This commit is contained in:
space-nuko
2023-06-20 00:16:06 -05:00
committed by GitHub
8 changed files with 37 additions and 23 deletions

View File

@@ -73,10 +73,10 @@ export default class ComfySetNodeModeAdvancedAction extends ComfyGraphNode {
if (hasTag) {
let newMode: NodeMode;
if (enable && action.enable) {
newMode = NodeMode.ALWAYS;
if (action.enable) {
newMode = enable ? NodeMode.ALWAYS : NodeMode.NEVER;
} else {
newMode = NodeMode.NEVER;
newMode = enable ? NodeMode.NEVER : NodeMode.ALWAYS;
}
nodeChanges[node.id] = newMode
}
@@ -88,7 +88,12 @@ export default class ComfySetNodeModeAdvancedAction extends ComfyGraphNode {
const container = entry.dragItem;
const hasTag = container.attrs.tags.indexOf(action.tag) != -1;
if (hasTag) {
const hidden = !(enable && action.enable)
let hidden: boolean;
if (action.enable) {
hidden = !enable
} else {
hidden = enable;
}
widgetChanges[container.id] = hidden
}
}

View File

@@ -170,7 +170,6 @@ export default class ComfyComboNode extends ComfyWidgetNode<string> {
super.stripUserState(o);
o.properties.values = []
o.properties.defaultValue = null;
(o as any).comfyValue = null
}
}

View File

@@ -357,9 +357,4 @@ export default abstract class ComfyWidgetNode<T = any> extends ComfyGraphNode {
this.value.set(value);
this.shownOutputProperties = (o as any).shownOutputProperties;
}
override stripUserState(o: SerializedLGraphNode) {
super.stripUserState(o);
(o as any).comfyValue = LiteGraph.cloneObject(this.properties.defaultValue);
}
}

View File

@@ -42,7 +42,7 @@
$: {
previewURL = $queueState.previewURL;
if (previewURL && $queueState.runningPromptID != null && !$uiState.hidePreviews && node.properties.showPreviews) {
if (previewURL && $queueState.runningPromptID && !$uiState.hidePreviews && node.properties.showPreviews) {
const queueEntry = queueState.getQueueEntry($queueState.runningPromptID)
if (queueEntry != null) {
const tags = queueEntry.extraData?.extra_pnginfo?.comfyBoxPrompt?.subgraphs;
@@ -51,12 +51,6 @@
previewImage = img;
})
}
else {
previewImage = null;
}
}
else {
previewImage = null;
}
}
else {
@@ -155,7 +149,7 @@
<div class="wrapper comfy-gallery-widget gradio-gallery" style={widget.attrs.style || ""}>
<Block variant="solid" padding={false}>
<div class="padding">
{#if previewImage}
{#if previewImage && $queueState.runningPromptID != null}
<div class="comfy-gallery-preview" on:mouseover={hidePreview} on:mouseout={showPreview} >
<img src={previewImage.src} bind:this={previewElem} on:mouseout={showPreview} />
</div>

View File

@@ -230,7 +230,7 @@
/>
{:else}
<div class="comfy-image-editor-panel">
{#if _value && canMask}
{#if _value && _value.length > 0 && canMask}
{@const comfyURL = convertComfyOutputToComfyURL(_value[0])}
<div class="mask-canvas-wrapper" style:display={editMask ? "block" : "none"}>
<MaskCanvas bind:this={maskCanvasComp} fileURL={comfyURL} on:release={onMaskReleased} on:loaded={onMaskReleased} />

View File

@@ -1,11 +1,12 @@
import ComfyGraph from "$lib/ComfyGraph";
import { ComfyNumberNode } from "$lib/nodes/widgets";
import { ComfyNumberNode, ComfyComboNode } from "$lib/nodes/widgets";
import { ComfyBoxWorkflow } from "$lib/stores/workflowState";
import { LiteGraph, Subgraph } from "@litegraph-ts/core";
import { get } from "svelte/store";
import { expect } from 'vitest';
import UnitTest from "./UnitTest";
import { Watch } from "@litegraph-ts/nodes-basic";
import type { SerializedComfyWidgetNode } from "$lib/nodes/widgets/ComfyWidgetNode";
export default class ComfyGraphTests extends UnitTest {
test__onNodeAdded__updatesLayoutState() {
@@ -107,4 +108,24 @@ export default class ComfyGraphTests extends UnitTest {
expect(serNode.outputs[0]._data).toBeUndefined()
}
test__serialize__savesComboData() {
const [{ graph }, layoutState] = ComfyBoxWorkflow.create()
layoutState.initDefaultLayout()
const widget = LiteGraph.createNode(ComfyComboNode);
const watch = LiteGraph.createNode(Watch);
graph.add(widget)
graph.add(watch)
widget.connect(0, watch, 0)
widget.properties.values = ["A", "B", "C"]
widget.setValue("B");
const result = graph.serialize();
const serNode = result.nodes.find(n => n.id === widget.id) as SerializedComfyWidgetNode;
expect(serNode.comfyValue).toBe("B")
}
}