]> git.openstreetmap.org Git - nominatim-ui.git/commitdiff
Cut down number of status fetch requests (#122)
authormtmail <mtmail@gmx.net>
Wed, 14 Apr 2021 15:28:56 +0000 (17:28 +0200)
committerGitHub <noreply@github.com>
Wed, 14 Apr 2021 15:28:56 +0000 (17:28 +0200)
src/components/LastUpdated.svelte

index a51b4b6a42e982b6e47235beea48305910b34e87..a5b3277e2408b86cbd797cecd30c131a3ae9355f 100644 (file)
@@ -6,11 +6,17 @@
 
   let last_updated_date;
   let last_api_request_url;
+  let fetch_running = false; // prevent multiple parallel fetch runs
 
   last_api_request_url_store.subscribe(url => {
+    if (fetch_running || last_updated_date) return;
+
+    fetch_running = true;
+
     last_api_request_url = url;
     fetch_from_api('status', { format: 'json' }, function (data) {
       last_updated_date = data.data_updated;
+      fetch_running = false;
     });
   });
 </script>