From e6ad1b3233ea987f90130d7f961ba46137e2c6a8 Mon Sep 17 00:00:00 2001
From: wxiaoguang <wxiaoguang@gmail.com>
Date: Wed, 19 Oct 2022 13:54:14 +0800
Subject: [PATCH] make RepoBuildView loadJobData work correctly, avoid
 concurrency requests.

---
 web_src/js/components/RepoBuildView.vue | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/web_src/js/components/RepoBuildView.vue b/web_src/js/components/RepoBuildView.vue
index 55c2cc60a3..6e6fee68b2 100644
--- a/web_src/js/components/RepoBuildView.vue
+++ b/web_src/js/components/RepoBuildView.vue
@@ -104,7 +104,10 @@ const sfc = {
     // TODO: the parent element's full height doesn't work well now
     const elBodyDiv = document.querySelector('body > div.full.height');
     elBodyDiv.style.height = '100%';
+
+    // load job data and then auto-reload periodically
     this.loadJobData();
+    setInterval(() => this.loadJobData(), 1000);
   },
 
   methods: {
@@ -140,7 +143,7 @@ const sfc = {
     toggleStepLogs(idx) {
       this.currentJobStepsStates[idx].expanded = !this.currentJobStepsStates[idx].expanded;
       if (this.currentJobStepsStates[idx].expanded) {
-        this.loadJobData(true);
+        this.loadJobData(); // try to load the data immediately instead of waiting for next timer interval
       }
     },
 
@@ -260,7 +263,7 @@ const sfc = {
       return await resp.json();
     },
 
-    async loadJobData(once) {
+    async loadJobData() {
       if (this.loading) return;
       try {
         this.loading = true;
@@ -297,9 +300,6 @@ const sfc = {
         }
       } finally {
         this.loading = false;
-        if (!once) {
-          setTimeout(() => this.loadJobData(), 1000);
-        }
       }
     }
   },