From 783449d626cf85bcb4632ba550959943bcebd4fd Mon Sep 17 00:00:00 2001 From: lavigor Date: Mon, 9 Jul 2018 02:26:19 +0300 Subject: [PATCH] [ticket/13713] Fix issue with duplicate queries PHPBB3-13713 --- phpBB/assets/javascript/editor.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/phpBB/assets/javascript/editor.js b/phpBB/assets/javascript/editor.js index f15b776889..2f854080eb 100644 --- a/phpBB/assets/javascript/editor.js +++ b/phpBB/assets/javascript/editor.js @@ -387,6 +387,7 @@ function getCaretPosition(txtarea) { (function($) { function Mentions() { let $mentionDataContainer = $('[data-mention-url]:first'); + let queryInProgress = null; let cachedNames = null; let cachedFor = null; let cachedSearchKey = 'name'; @@ -449,10 +450,20 @@ function getCaretPosition(txtarea) { return; } + /* + * Do not make a new request until the previous one for the same query is returned + * This fixes duplicate server queries e.g. when arrow keys are pressed + */ + if (queryInProgress === query) { + return; + } + queryInProgress = query; + let params = {keyword: query, topic_id: mentionTopicId, _referer: location.href}; $.getJSON(mentionURL, params, function (data) { cachedNames = data; cachedFor = query; + queryInProgress = null; callback(data); }); },