mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2024-11-22 16:23:28 +01:00
added audio ding
This commit is contained in:
parent
f58c16ab03
commit
1b439c15f6
@ -79,9 +79,5 @@ export const doMakeImage = async (reqBody: ImageRequest) => {
|
||||
},
|
||||
body: JSON.stringify(reqBody),
|
||||
});
|
||||
console.log('doMakeImage= GOT RESPONSE', res);
|
||||
|
||||
// const data = await res.json();
|
||||
// return data;
|
||||
return res;
|
||||
};
|
||||
|
@ -13,3 +13,4 @@ const AudioDing = React.forwardRef((props, ref) => (
|
||||
AudioDing.displayName = "AudioDing";
|
||||
|
||||
export default AudioDing;
|
||||
|
||||
|
@ -6,8 +6,6 @@ import ModifierTag from "../../../../atoms/modifierTag";
|
||||
export default function ActiveTags() {
|
||||
const selectedtags = useImageCreate((state) => state.selectedTags());
|
||||
|
||||
console.log("ActiveTags", selectedtags);
|
||||
|
||||
return (
|
||||
<div className="selected-tags">
|
||||
<p>Active Tags</p>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import React, { useEffect } from "react";
|
||||
import React, { useEffect, useRef } from "react";
|
||||
|
||||
import { useImageCreate, ImageRequest } from "../../../../../stores/imageCreateStore";
|
||||
import { useImageQueue } from "../../../../../stores/imageQueueStore";
|
||||
@ -25,6 +25,8 @@ import AudioDing from "../../../../molecules/audioDing";
|
||||
export default function MakeButton() {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const dingRef = useRef<HTMLAudioElement>(null);
|
||||
|
||||
const parallelCount = useImageCreate((state) => state.parallelCount);
|
||||
const builtRequest = useImageCreate((state) => state.builtRequest);
|
||||
const isRandomSeed = useImageCreate((state) => state.isRandomSeed());
|
||||
@ -100,18 +102,18 @@ export default function MakeButton() {
|
||||
}
|
||||
|
||||
const parseRequest = async (id: string, reader: ReadableStreamDefaultReader<Uint8Array>) => {
|
||||
console.log('parseRequest');
|
||||
const decoder = new TextDecoder();
|
||||
let finalJSON = '';
|
||||
|
||||
console.log('id', id);
|
||||
//console.log('id', id);
|
||||
while (true) {
|
||||
const { done, value } = await reader.read();
|
||||
const jsonStr = decoder.decode(value);
|
||||
if (done) {
|
||||
removeFirstInQueue();
|
||||
setStatus(FetchingStates.COMPLETE);
|
||||
hackJson(finalJSON)
|
||||
hackJson(finalJSON);
|
||||
void dingRef.current?.play();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -262,14 +264,17 @@ export default function MakeButton() {
|
||||
}, [hasQueue, status, id, options, startStream]);
|
||||
|
||||
return (
|
||||
<button
|
||||
className={MakeButtonStyle}
|
||||
onClick={() => {
|
||||
void makeImageQueue();
|
||||
}}
|
||||
disabled={hasQueue}
|
||||
>
|
||||
{t("home.make-img-btn")}
|
||||
</button>
|
||||
<>
|
||||
<button
|
||||
className={MakeButtonStyle}
|
||||
onClick={() => {
|
||||
void makeImageQueue();
|
||||
}}
|
||||
disabled={hasQueue}
|
||||
>
|
||||
{t("home.make-img-btn")}
|
||||
</button>
|
||||
<AudioDing ref={dingRef}></AudioDing>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import React, { useEffect, useState, useRef } from "react";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { healthPing, HEALTH_PING_INTERVAL } from "../../../../api";
|
||||
|
||||
import AudioDing from "../../../molecules/audioDing";
|
||||
|
||||
import {
|
||||
StartingStatus,
|
||||
ErrorStatus,
|
||||
@ -17,6 +19,8 @@ export default function StatusDisplay({ className }: { className?: string }) {
|
||||
const [statusMessage, setStatusMessage] = useState(startingMessage);
|
||||
const [statusClass, setStatusClass] = useState(StartingStatus);
|
||||
|
||||
const dingRef = useRef<HTMLAudioElement>(null);
|
||||
|
||||
// but this will be moved to the status display when it is created
|
||||
const { status, data } = useQuery(["health"], healthPing, {
|
||||
refetchInterval: HEALTH_PING_INTERVAL,
|
||||
@ -33,16 +37,20 @@ export default function StatusDisplay({ className }: { className?: string }) {
|
||||
if (data[0] === "OK") {
|
||||
setStatusMessage(successMessage);
|
||||
setStatusClass(SuccessStatus);
|
||||
// catch an auto play error
|
||||
dingRef.current?.play().catch((e) => {
|
||||
console.log('DING!')
|
||||
});
|
||||
} else {
|
||||
setStatusMessage(errorMessage);
|
||||
setStatusClass(ErrorStatus);
|
||||
}
|
||||
}
|
||||
}, [status, data]);
|
||||
}, [status, data, dingRef]);
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* alittle hacky but joins the class names, will probably need a better css in js solution or tailwinds */}
|
||||
<AudioDing ref={dingRef}></AudioDing>
|
||||
<p className={[statusClass, className].join(" ")}>{statusMessage}</p>
|
||||
</>
|
||||
);
|
||||
|
42
ui/frontend/dist/index.js
vendored
42
ui/frontend/dist/index.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user