From 3cbbb2fe3927734897f3b1c743e86f6603269609 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Fri, 19 Jul 2024 02:12:01 +0300 Subject: [PATCH] Use eventSource instead of DOM click --- public/scripts/extensions/stable-diffusion/index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/public/scripts/extensions/stable-diffusion/index.js b/public/scripts/extensions/stable-diffusion/index.js index d43031950..008ef0f15 100644 --- a/public/scripts/extensions/stable-diffusion/index.js +++ b/public/scripts/extensions/stable-diffusion/index.js @@ -2294,14 +2294,13 @@ async function generatePicture(initiator, args, trigger, message, callback) { let imagePath = ''; const stopListener = () => abortController.abort('Aborted by user'); - const mesStop = document.getElementById('mes_stop'); try { const combineNegatives = (prefix) => { negativePromptPrefix = combinePrefixes(negativePromptPrefix, prefix); }; const prompt = await getPrompt(generationType, message, trigger, quietPrompt, combineNegatives); console.log('Processed image prompt:', prompt); - mesStop?.addEventListener('click', stopListener); + eventSource.once(event_types.GENERATION_STOPPED, stopListener); context.deactivateSendButtons(); hideSwipeButtons(); @@ -2316,7 +2315,7 @@ async function generatePicture(initiator, args, trigger, message, callback) { } finally { restoreOriginalDimensions(dimensions); - mesStop?.removeEventListener('click', stopListener); + eventSource.removeListener(event_types.GENERATION_STOPPED, stopListener); context.activateSendButtons(); showSwipeButtons(); }