mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-13 09:50:08 -04:00
Delay the initial AJAX call by 2 seconds
At the moment the first AJAX call is triggered as soon as the page loads. We then look at its response time to work out how long to wait until making the next call. This isn’t great because: - stuff is unlikely to have changed straight away, so it’s a waste of a call - while the DOM is being updated it seems to introduce a delay in clicks on links, which is either more pronounced or more noticeable when it’s happening straight away, making the UI feel less snappy I chose a value of 2 seconds as a rough proxy for the minimum time we’d expect to see a notification go from created to delivered. Median time-to-delivered was 2.9 seconds when we analysed it for https://github.com/alphagov/notifications-admin/pull/2974#discussion_r286101286
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
var queues = {};
|
||||
var dd = new global.diffDOM();
|
||||
var defaultInterval = 2000;
|
||||
var interval = 0;
|
||||
|
||||
var calculateBackoff = responseTime => parseInt(Math.max(
|
||||
@@ -54,11 +55,14 @@
|
||||
|
||||
global.GOVUK.Modules.UpdateContent = function() {
|
||||
|
||||
this.start = component => poll(
|
||||
getRenderer($(component)),
|
||||
$(component).data('resource'),
|
||||
getQueue($(component).data('resource')),
|
||||
$(component).data('form')
|
||||
this.start = component => setTimeout(
|
||||
() => poll(
|
||||
getRenderer($(component)),
|
||||
$(component).data('resource'),
|
||||
getQueue($(component).data('resource')),
|
||||
$(component).data('form')
|
||||
),
|
||||
defaultInterval
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user