diff --git a/resources/assets/vue/components/general/elements/ListPollingComponent.vue b/resources/assets/vue/components/general/elements/ListPollingComponent.vue index 35e17705..98e2a44b 100644 --- a/resources/assets/vue/components/general/elements/ListPollingComponent.vue +++ b/resources/assets/vue/components/general/elements/ListPollingComponent.vue @@ -135,15 +135,34 @@ this.isPolling = false; // this.isLoading = false; }, - startPolling(jobId) { - // this.fetchJobResult(jobId); // Start immediately - this.pollingInterval = setInterval(() => { + startPolling(jobId, maxAttempts = 3) { + let attempts = 0; + const pollJobResult = () => { if (this.isPolling) { return; } this.isPolling = true; - this.fetchJobResult(jobId); // Replace with the actual job ID - }, 10000); // Poll every 5 seconds + + attempts++; + + if (attempts > maxAttempts) { + clearInterval(this.pollingInterval); + this.pollingInterval = null; + this.isPolling = false; + this.isLoading = false; + console.log(`Reached maximum attempts (${maxAttempts}). Polling stopped.`); + return; + } + + this.fetchJobResult(jobId); + }; + + // Initial call + // pollJobResult(); + + // Set up polling interval + this.pollingInterval = setInterval(pollJobResult, 10000); + }, stopPolling() { clearInterval(this.pollingInterval);