mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2024-12-25 16:38:55 +01:00
fix ordering
This commit is contained in:
parent
a6394b2dce
commit
b8f47545ed
@ -24,6 +24,7 @@ import {
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
import AudioDing from "../../../../molecules/audioDing";
|
import AudioDing from "../../../../molecules/audioDing";
|
||||||
|
import { debug } from "console";
|
||||||
|
|
||||||
export default function MakeButton() {
|
export default function MakeButton() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@ -95,19 +96,16 @@ export default function MakeButton() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const parseRequest = async (id: string, reader: ReadableStreamDefaultReader<Uint8Array>) => {
|
const parseRequest = async (id: string, reader: ReadableStreamDefaultReader<Uint8Array>) => {
|
||||||
|
console.log('parseRequest');
|
||||||
const decoder = new TextDecoder();
|
const decoder = new TextDecoder();
|
||||||
let finalJSON = '';
|
let finalJSON = '';
|
||||||
|
|
||||||
console.log('id', id);
|
console.log('id', id);
|
||||||
|
|
||||||
// TODO MAKE SPACE IN THE DISPLAY FOR THIS IMAGE
|
|
||||||
// UPDATE THE DISPLAY WITH THE PROGRESS IMAGE
|
|
||||||
// UPDATE THE DISPLAY WITH THE FINAL IMAGE
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
const { done, value } = await reader.read();
|
const { done, value } = await reader.read();
|
||||||
const jsonStr = decoder.decode(value);
|
const jsonStr = decoder.decode(value);
|
||||||
if (done as boolean) {
|
if (done as boolean) {
|
||||||
|
removeFirstInQueue();
|
||||||
setStatus(FetchingStates.COMPLETE);
|
setStatus(FetchingStates.COMPLETE);
|
||||||
hackJson(finalJSON)
|
hackJson(finalJSON)
|
||||||
break;
|
break;
|
||||||
@ -123,10 +121,9 @@ export default function MakeButton() {
|
|||||||
setTotalSteps(total_steps);
|
setTotalSteps(total_steps);
|
||||||
|
|
||||||
console.log('progess step of total', step, total_steps);
|
console.log('progess step of total', step, total_steps);
|
||||||
|
|
||||||
if (void 0 !== outputs) {
|
if (void 0 !== outputs) {
|
||||||
outputs.forEach((output: any) => {
|
outputs.forEach((output: any) => {
|
||||||
// console.log('progress path', output.path);
|
console.log('progress path', output.path);
|
||||||
addProgressImage(output.path);
|
addProgressImage(output.path);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -155,12 +152,14 @@ export default function MakeButton() {
|
|||||||
|
|
||||||
const startStream = async (id: string, req: ImageRequest) => {
|
const startStream = async (id: string, req: ImageRequest) => {
|
||||||
|
|
||||||
|
console.log('START STREAM', id);
|
||||||
const streamReq = {
|
const streamReq = {
|
||||||
...req,
|
...req,
|
||||||
stream_image_progress: true,
|
stream_image_progress: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setStatus(FetchingStates.FETCHING);
|
||||||
const res = await doMakeImage(streamReq);
|
const res = await doMakeImage(streamReq);
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
const reader = res.body.getReader();
|
const reader = res.body.getReader();
|
||||||
@ -230,6 +229,12 @@ export default function MakeButton() {
|
|||||||
// potentially update the seed
|
// potentially update the seed
|
||||||
await startStream(id, options);
|
await startStream(id, options);
|
||||||
}
|
}
|
||||||
|
console.log('USE EFFECT', hasQueue);
|
||||||
|
console.log('status', status);
|
||||||
|
|
||||||
|
if (status === FetchingStates.PROGRESSING || status === FetchingStates.FETCHING) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (hasQueue) {
|
if (hasQueue) {
|
||||||
makeImages(options).catch((e) => {
|
makeImages(options).catch((e) => {
|
||||||
@ -239,22 +244,21 @@ export default function MakeButton() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}, [hasQueue, id, options, startStream]);
|
}, [hasQueue, status, id, options, startStream]);
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
// if the status is complete we can remove the image from the queue
|
// // if the status is complete we can remove the image from the queue
|
||||||
if (status === FetchingStates.COMPLETE) {
|
// if (status === FetchingStates.COMPLETE) {
|
||||||
// debugger;
|
// // debugger;
|
||||||
removeFirstInQueue();
|
// removeFirstInQueue();
|
||||||
}
|
// }
|
||||||
}, [removeFirstInQueue, status]);
|
// }, [removeFirstInQueue, status]);
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
className={MakeButtonStyle}
|
className={MakeButtonStyle}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setStatus(FetchingStates.FETCHING);
|
|
||||||
void makeImageQueue();
|
void makeImageQueue();
|
||||||
}}
|
}}
|
||||||
disabled={hasQueue}
|
disabled={hasQueue}
|
||||||
|
Loading…
Reference in New Issue
Block a user