MCPcopy Index your code
hub / github.com/easydiffusion/easydiffusion / onRenderTaskCompleted

Function onRenderTaskCompleted

ui/media/js/task-manager.js:251–327  ·  view source on GitHub ↗
(task, reqBody, instance, outputContainer, stepUpdate)

Source from the content-addressed store, hash-verified

249}
250
251function onRenderTaskCompleted(task, reqBody, instance, outputContainer, stepUpdate) {
252 if (typeof stepUpdate === "object") {
253 if (stepUpdate.status === "succeeded") {
254 document.dispatchEvent(
255 new CustomEvent("on_render_task_success", {
256 detail: {
257 task: task,
258 reqBody: reqBody,
259 stepUpdate: stepUpdate,
260 outputContainer: outputContainer,
261 },
262 })
263 )
264 } else {
265 task.isProcessing = false
266 document.dispatchEvent(
267 new CustomEvent("on_render_task_fail", {
268 detail: {
269 task: task,
270 reqBody: reqBody,
271 stepUpdate: stepUpdate,
272 outputContainer: outputContainer,
273 },
274 })
275 )
276 }
277 }
278 if (task.isProcessing && task.batchesDone < task.batchCount) {
279 task["taskStatusLabel"].innerText = "Pending"
280 task["taskStatusLabel"].classList.add("waitingTaskLabel")
281 task["taskStatusLabel"].classList.remove("activeTaskLabel")
282 return
283 }
284 if ("instances" in task && task.instances.some((ins) => ins != instance && ins.isPending)) {
285 return
286 }
287
288 task.isProcessing = false
289 task["stopTask"].innerHTML = '<i class="fa-solid fa-trash-can"></i> Remove'
290 task["taskStatusLabel"].style.display = "none"
291
292 let time = millisecondsToStr(Date.now() - task.startTime)
293
294 if (task.batchesDone == task.batchCount) {
295 if (!task.outputMsg.innerText.toLowerCase().includes("error")) {
296 task.outputMsg.innerText = `Processed ${task.numOutputsTotal} images in ${time}`
297 }
298 task.progressBar.style.height = "0px"
299 task.progressBar.style.border = "0px solid var(--background-color3)"
300 task.progressBar.classList.remove("active")
301 // setStatus("request", "done", "success")
302 } else {
303 task.outputMsg.innerText += `. Task ended after ${time}`
304 }
305
306 // if (randomSeedField.checked) { // we already update this before the task starts
307 // seedField.value = task.seed
308 // }

Callers 1

onTaskStartFunction · 0.85

Calls 4

millisecondsToStrFunction · 0.85
dispatchEventMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected