Skip to content

Commit

Permalink
Disable the Enqueue button when prompt is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
breadthe committed Nov 20, 2022
1 parent 31e3c87 commit 701a019
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/lib/Generate.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,20 @@
resetPromptMatrix()
}
// disable the Generate button when these conditions are met
$: disableGenerate =
// disable the Enqueue button when these conditions are met
$: disableEnqueue =
!$stableDiffusionDirectory || // no stable diffusion directory
!$pythonPath || // python path is not set
$prompt.trim() === "" || // prompt is empty
numPromptTokens > 80 || // giving user a bit more leeway than strictly 75 since we're estimating
$isGenerating || // disable while generating
// if there are custom vars, make sure they're all filled
($extractedVars.length && !$allCustomVarsAreFilled)
// disable the Generate button when these conditions are met
$: disableGenerate =
disableEnqueue || // all the conditions for disabling the Enqueue button
$isGenerating // and in addition disable while generating
$: if ($startQueue) {
console.log("processing queue")
startQueue.set(false)
Expand Down Expand Up @@ -378,7 +382,7 @@
</div>

<div class="flex items-center justify-between gap-4">
<PushToQueueBtn {disableGenerate} {copies} />
<PushToQueueBtn {disableEnqueue} {copies} />

<!-- Generate button -->
<button
Expand Down
3 changes: 2 additions & 1 deletion src/lib/queue/PushToQueueBtn.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
useRandomSeed,
} from "../../store"
export let disableGenerate: boolean = false
export let disableEnqueue: boolean = false
export let copies: number = 1
function pushToQueue() {
Expand Down Expand Up @@ -109,6 +109,7 @@

<button
class="flex items-center"
disabled={disableEnqueue}
on:click={pushToQueue}
title="Push the current prompt or prompt matrix to the queue"
use:tooltip={{ theme: isDark() ? "dark-border" : "light-border" }}
Expand Down

0 comments on commit 701a019

Please sign in to comment.