]> git.cworth.org Git - zombocom-ai/commitdiff
Hide image-generation form while generation is happening
authorCarl Worth <cworth@cworth.org>
Thu, 8 Dec 2022 00:35:49 +0000 (16:35 -0800)
committerCarl Worth <cworth@cworth.org>
Thu, 8 Dec 2022 00:41:57 +0000 (16:41 -0800)
Giving the user a queue that something is happening (and helping to
avoid queueing the generation of multiple identical images).

index.html
index.js

index 334a390ed6cda913ac86a900ebaa1acd0f8aa157..a0ee564da71d9cf9498743c1ccc2bf1ee2e93617 100644 (file)
@@ -142,10 +142,17 @@ mute.addEventListener("click", () => {
 
     zombo_form.addEventListener('submit', function(e) {
         e.preventDefault();
+        /* Hide the form while generation is happening. */
+        zombo_form.style.display = "none";
         socket.emit('generate', {"prompt": prompt.value, "code": code.value});
         prompt.value = '';
     });
 
+    socket.on('generation-done', () => {
+        /* Re-display the form now that image-generation is over. */
+        zombo_form.style.display = "grid";
+    });
+
     // TODO: Dynamically generate many different prompts here
     safety.addEventListener("click", () => {
         prompt.value = "Matte painting of a Samurai warrior";
index 0ee5e4359255f4afe794114cd043950d0da2c85e..ba01d67ffbe60b85403b5026e514b51f34d9a389 100644 (file)
--- a/index.js
+++ b/index.js
@@ -85,6 +85,7 @@ io.on('connection', (socket) => {
                 console.log("Error occurred during generate-image: " + data);
             });
             const { stdout, stderr } = await promise;
+            socket.emit('generation-done');
         }
         generate_image(request['code'], request['prompt']);
     });