From: mtmail Date: Wed, 14 Apr 2021 15:28:56 +0000 (+0200) Subject: Cut down number of status fetch requests (#122) X-Git-Url: https://git.openstreetmap.org./nominatim-ui.git/commitdiff_plain/82eae94284b6f0be5eeb1bc7e90350c4992994bf Cut down number of status fetch requests (#122) --- diff --git a/src/components/LastUpdated.svelte b/src/components/LastUpdated.svelte index a51b4b6..a5b3277 100644 --- a/src/components/LastUpdated.svelte +++ b/src/components/LastUpdated.svelte @@ -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; }); });