Fixed duplicated polling timers

This commit is contained in:
Joel Collins 2020-11-06 10:32:47 +00:00
parent ac382b7fab
commit fcd9fa4990

View file

@ -94,7 +94,6 @@ export default {
return { return {
taskId: null, taskId: null,
taskUrl: null, taskUrl: null,
polling: null,
progress: null, progress: null,
taskStarted: false, taskStarted: false,
taskRunning: false taskRunning: false
@ -182,38 +181,40 @@ export default {
}, },
startPolling: function(taskId, taskUrl) { startPolling: function(taskId, taskUrl) {
// Starts polling an existing Action task if (this.taskRunning != true) {
this.taskId = taskId; // Starts polling an existing Action task
this.taskUrl = taskUrl; this.taskId = taskId;
// Start the store polling TaskId for success this.taskUrl = taskUrl;
this.taskRunning = true; // Start the store polling TaskId for success
this.$emit("taskRunning", this.taskId); this.taskRunning = true;
this.pollTask(this.taskId, this.pollInterval) this.$emit("taskRunning", this.taskId);
.then(response => { this.pollTask(this.taskId, this.pollInterval)
// Do something with the final response .then(response => {
console.log("Emitting onResponse: ", response); // Do something with the final response
this.$emit("response", response); console.log("Emitting onResponse: ", response);
this.$emit("finished"); this.$emit("response", response);
}) this.$emit("finished");
.catch(error => { })
if (!error) { .catch(error => {
error = Error("Unknown error"); if (!error) {
} error = Error("Unknown error");
console.log("Emitting onError: ", error); }
this.$emit("error", error); console.log("Emitting onError: ", error);
this.$emit("finished"); this.$emit("error", error);
}) this.$emit("finished");
.finally(() => { })
console.log("Cleaning up after task."); .finally(() => {
// Reset taskRunning and taskId console.log("Cleaning up after task.");
this.taskRunning = false; // Reset taskRunning and taskId
this.taskStarted = false; this.taskRunning = false;
this.taskId = null; this.taskStarted = false;
// Update the form data if we're self-updating this.taskId = null;
if (this.selfUpdate) { // Update the form data if we're self-updating
this.getFormData(); if (this.selfUpdate) {
} this.getFormData();
}); }
});
}
}, },
pollTask: function(taskId, interval) { pollTask: function(taskId, interval) {