From 3cbea2851d561f76a9d2ccaa37bb9c1d99a988f8 Mon Sep 17 00:00:00 2001 From: Mathias Brodala Date: Fri, 9 Apr 2021 15:36:48 +0200 Subject: [PATCH] [BUGFIX] Prevent result duplication on slow search The search logic happens in a timer, if a search is too slow than the configured delay, the same search will be performed again. This leads to the same results being appended again and again until the situation normalizes over time. To avoid this, we directly update the last term and page every time the search is processed instead of doing this after the search results where retrieved. --- Resources/Public/JavaScript/searchable.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Resources/Public/JavaScript/searchable.js b/Resources/Public/JavaScript/searchable.js index d5e55aed..b93b57ef 100644 --- a/Resources/Public/JavaScript/searchable.js +++ b/Resources/Public/JavaScript/searchable.js @@ -108,7 +108,8 @@ } - + lastTerm = searchTerm; + lastPage = currentPage; timer = setTimeout(function(){callAjaxSearch()}, settings.delay); } @@ -148,8 +149,6 @@ }, data, this); } - lastTerm = searchTerm; - lastPage = currentPage; result = data; populate(); updateUI();