diff options
author | Matthew Somerville <matthew@mysociety.org> | 2020-03-31 13:45:22 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2020-03-31 13:45:24 +0100 |
commit | c0f2abdbfcea725aaf32404fbf1e263585a69835 (patch) | |
tree | 4b6e33b08084b6db94e92b52777fb1acbc70e75d /web/js | |
parent | 10b16b9dac996f3593326245993579ceff5d74bd (diff) |
Only one duplicate call in progress at once.
Without this check, it is possible for calls to overlap and end up with
a situation whereby both the duplicate list and the form are hidden.
Diffstat (limited to 'web/js')
-rw-r--r-- | web/js/duplicates.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/web/js/duplicates.js b/web/js/duplicates.js index 4f1574c0f..853456932 100644 --- a/web/js/duplicates.js +++ b/web/js/duplicates.js @@ -13,11 +13,18 @@ // but undefined on new report page. var report_id = $("#report_inspect_form .js-report-id").text() || undefined; + // Don't make another call whilst one is in progress + var in_progress = false; + function refresh_duplicate_list(evt, params, category) { if (params && params.skip_duplicates) { return; } + if (in_progress) { + return; + } + if (!category) { category = $('select[name="category"]').val(); } @@ -57,6 +64,7 @@ } } + in_progress = true; $.ajax({ url: nearby_url, data: url_params, @@ -87,7 +95,9 @@ $("#js-duplicate-reports ul").empty().prepend( $reports ); fixmystreet.set_up.fancybox_images(); - $('#js-duplicate-reports').hide().removeClass('hidden').slideDown(); + $('#js-duplicate-reports').hide().removeClass('hidden').slideDown(function(){ + in_progress = false; + }); if ( $('#problem_form').length ) { $('.js-hide-if-invalid-category').slideUp(); $('.js-hide-if-invalid-category_extras').slideUp(); @@ -175,6 +185,7 @@ $('#js-duplicate-reports').slideUp(function(){ $(this).addClass('hidden'); $(this).find('ul').empty(); + in_progress = false; }); if ($('#problem_form').length && take_effect()) { $('.js-hide-if-invalid-category').slideDown(); |