More control over how gallery selects images from events

This commit is contained in:
space-nuko
2023-05-22 20:42:41 -05:00
parent 6817e6ad95
commit e90773fdc8
14 changed files with 96 additions and 25 deletions

View File

@@ -80,11 +80,18 @@
updateFromQueue();
changed = false;
}
else if (mode === "history" && (changed || ($queueCompleted && $queueCompleted.length != _entries.length))) {
else if (mode === "history" && (changed || ($queueCompleted && $queueCompleted.length != _entries.length))) {
updateFromHistory();
changed = false;
}
$: if (mode === "queue" && !$queuePending && !$queueRunning) {
_queuedEntries = []
_runningEntries = []
_entries = [];
changed = true
}
async function deleteEntry(entry: QueueUIEntry, event: MouseEvent) {
event.preventDefault();
event.stopImmediatePropagation()

View File

@@ -53,6 +53,7 @@
<div id="dropzone"
class="dropzone"
bind:this={dropZone}
on:pointerdown={hideDropZone}
on:dragover={allowDrag}
on:dragleave={hideDropZone}
on:drop={handleDrop}

View File

@@ -200,12 +200,14 @@
elem_id="comfy-image-upload-block"
{elem_classes}
>
<BlockLabel
label={label}
show_label={label != ""}
Icon={FileIcon}
float={label != ""}
/>
{#if label != ""}
<BlockLabel
label={label}
show_label={label != ""}
Icon={FileIcon}
float={label != ""}
/>
{/if}
{#if value && value.length > 0 && !pending_upload}
{@const firstImage = value[0]}
<ModifyUpload on:clear={handle_clear} absolute />

View File

@@ -51,12 +51,20 @@
let prevValue: string[] | FileData[] | null = value;
export let selected_image: number | null = null;
let old_selected_image: number | null = null;
export let forceSelectImage: boolean | null = null;
$: if (prevValue !== value) {
// When value is falsy (clear button or first load),
// style.preview determines the selected image
if (was_reset) {
selected_image = style.preview && value?.length ? 0 : null;
let selectImage: boolean = Boolean(style.preview && value?.length)
let selectedIndex = 0;
if (forceSelectImage != null) {
selectImage = forceSelectImage
selectedIndex = selected_image;
forceSelectImage = null;
}
selected_image = selectImage ? selectedIndex : null;
was_reset = false;
// Otherwise we keep the selected_image the same if the
// gallery has at least as many elements as it did before

View File

@@ -23,7 +23,7 @@
{#if receiveTargets.length > 0}
{#each receiveTargets as { workflow, targetNodes }}
<Block>
<BlockTitle>{workflow.attrs.title}</BlockTitle>
<BlockTitle>Workflow: <b>{workflow.attrs.title}</b></BlockTitle>
{#each targetNodes as targetNode}
<Block>
<div class="target">