Skip to content

Commit a81e1af

Browse files
committed
fix: stop generation of image when generation popup is closed
1 parent 0a70ddd commit a81e1af

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

custom/imageGenerator.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
{{ $t('Generate image with AI') }}
1212
</h3>
1313
<button type="button"
14-
@click="emit('close')"
14+
@click="() => {stopGeneration = true; emit('close')}"
1515
class="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 ms-auto inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white" >
1616
<svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
1717
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
@@ -161,7 +161,7 @@
161161
disabled:opacity-50 disabled:cursor-not-allowed"
162162
>{{ $t('Use image') }}</button>
163163
<button type="button" class="py-2.5 px-5 ms-3 text-sm font-medium text-gray-900 focus:outline-none bg-white rounded-lg border border-gray-200 hover:bg-gray-100 hover:text-blue-700 focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700"
164-
@click="emit('close')"
164+
@click="() => {stopGeneration = true; emit('close')}"
165165
>{{ $t('Cancel') }}</button>
166166
</div>
167167
</div>
@@ -190,6 +190,7 @@ const props = defineProps(['meta', 'record']);
190190
const images = ref([]);
191191
const loading = ref(false);
192192
const attachmentFiles = ref<string[]>([])
193+
const stopGeneration = ref(false);
193194
194195
function minifyField(field: string): string {
195196
if (field.length > 100) {
@@ -390,7 +391,7 @@ async function generateImages() {
390391
}
391392
}
392393
await new Promise((resolve) => setTimeout(resolve, 2000));
393-
} while (jobStatus === 'in_progress' || jobStatus === null)
394+
} while ((jobStatus === 'in_progress' || jobStatus === null) && !stopGeneration.value);
394395
395396
if (error) {
396397
adminforth.alert({

0 commit comments

Comments
 (0)