Merge pull request #152 from vladmandic/main

fix leave-page alert - @zero01101 need to add to contributor wiki page later
This commit is contained in:
Victor Seiji Hariki 2023-01-04 18:14:35 -03:00 committed by GitHub
commit eeb25b8915
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,7 +1,6 @@
let blockNewImages = false;
let generationQueue = [];
let generationAreas = new Set();
let generating = false;
/**
* Starts progress monitoring bar
@ -76,6 +75,16 @@ const _monitorProgress = (bb, oncheck = null) => {
};
};
let busy = false
const generating = (val) => {
busy = val
if (busy) {
window.onbeforeunload = async () => { await sendInterrupt(); };
} else {
window.onbeforeunload = null
}
}
/**
* Starts a dream
*
@ -129,7 +138,7 @@ const _dream = async (endpoint, request) => {
/** @type {StableDiffusionResponse} */
let data = null;
try {
generating = true;
generating(true);
if (
endpoint == "txt2img" &&
request.enable_hr &&
@ -176,7 +185,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 +733,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 +2213,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;
};