Skip to content

Commit b772acd

Browse files
committed
Stop polling on unmount job item component
1 parent b559e8c commit b772acd

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

resources/js/screens/jobs/item.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
data() {
4242
return {
4343
job: {},
44+
isMounted: true,
4445
};
4546
},
4647
@@ -49,6 +50,10 @@
4950
this.autoRefreshData();
5051
},
5152
53+
beforeDestroy() {
54+
this.isMounted = false;
55+
},
56+
5257
computed: {
5358
processOutput() {
5459
if (!this.job.process) {
@@ -62,6 +67,10 @@
6267
methods: {
6368
async autoRefreshData() {
6469
setTimeout(async () => {
70+
if (this.isMounted === false) {
71+
return;
72+
}
73+
6574
if (this.job.status === 'Pending' || this.job.status === 'Running') {
6675
await this.fetchData();
6776
await this.autoRefreshData();

0 commit comments

Comments
 (0)