fix leave-page alert
This commit is contained in:
parent
488e16ede1
commit
9ab0991f4d
1 changed files with 14 additions and 11 deletions
|
@ -1,7 +1,6 @@
|
|||
let blockNewImages = false;
|
||||
let generationQueue = [];
|
||||
let generationAreas = new Set();
|
||||
let generating = false;
|
||||
|
||||
/**
|
||||
* Starts progress monitoring bar
|
||||
|
@ -76,6 +75,17 @@ const _monitorProgress = (bb, oncheck = null) => {
|
|||
};
|
||||
};
|
||||
|
||||
let busy = false
|
||||
const generating = (val) => {
|
||||
console.log('GENERATING', val)
|
||||
busy = val
|
||||
if (busy) {
|
||||
window.onbeforeunload = async () => { await sendInterrupt(); };
|
||||
} else {
|
||||
window.onbeforeunload = null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a dream
|
||||
*
|
||||
|
@ -129,7 +139,7 @@ const _dream = async (endpoint, request) => {
|
|||
/** @type {StableDiffusionResponse} */
|
||||
let data = null;
|
||||
try {
|
||||
generating = true;
|
||||
generating(true);
|
||||
if (
|
||||
endpoint == "txt2img" &&
|
||||
request.enable_hr &&
|
||||
|
@ -176,7 +186,7 @@ const _dream = async (endpoint, request) => {
|
|||
|
||||
data = await response.json();
|
||||
} finally {
|
||||
generating = false;
|
||||
generating(false);
|
||||
}
|
||||
var responseSubdata = JSON.parse(data.info);
|
||||
var returnData = {
|
||||
|
@ -724,9 +734,7 @@ const _generate = async (endpoint, request, bb, options = {}) => {
|
|||
mouse.listen.world.btn.middle.onclick.clear(onmorehandler);
|
||||
mouse.listen.world.onwheel.clear(onwheelhandler);
|
||||
isDreamComplete = true;
|
||||
if (generating) {
|
||||
sendInterrupt();
|
||||
}
|
||||
generating(false)
|
||||
};
|
||||
|
||||
redraw();
|
||||
|
@ -2206,11 +2214,6 @@ const img2imgTool = () =>
|
|||
}
|
||||
);
|
||||
|
||||
window.onbeforeunload = async () => {
|
||||
// Stop current generation on page close
|
||||
if (generating) await sendInterrupt();
|
||||
};
|
||||
|
||||
const sendSeed = (seed) => {
|
||||
stableDiffusionData.seed = document.getElementById("seed").value = seed;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue