diff options
author | Sam Rose <sam@gitlab.com> | 2017-01-07 18:29:10 -0500 |
---|---|---|
committer | samrose3 <sam@gitlab.com> | 2017-01-25 19:25:27 -0500 |
commit | 72e0ed0aa9b2e5a3190854a486fcd3570ad1230b (patch) | |
tree | 85518d0f1486d4f8d648f91a3f41bbdfbfc1fabb /app | |
parent | b60de9c0fd90c310d2a4146f75b67f9f360cbd6c (diff) | |
download | gitlab-ce-72e0ed0aa9b2e5a3190854a486fcd3570ad1230b.tar.gz |
Only search commits on input change since last search26448-unnecessary-request-is-made-when-filter-input-box-is-focused-by-keyboard
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/commits.js | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/app/assets/javascripts/commits.js b/app/assets/javascripts/commits.js index cabeae74ae3..c6fdfbcaa10 100644 --- a/app/assets/javascripts/commits.js +++ b/app/assets/javascripts/commits.js @@ -3,7 +3,7 @@ (function() { this.CommitsList = (function() { - function CommitsList() {} + var CommitsList = {}; CommitsList.timer = null; @@ -20,6 +20,7 @@ }); this.content = $("#commits-list"); this.searchField = $("#commits-search"); + this.lastSearch = this.searchField.val(); return this.initSearch(); }; @@ -37,6 +38,7 @@ var commitsUrl, form, search; form = $(".commits-search-form"); search = CommitsList.searchField.val(); + if (search === CommitsList.lastSearch) return; commitsUrl = form.attr("action") + '?' + form.serialize(); CommitsList.content.fadeTo('fast', 0.5); return $.ajax({ @@ -47,12 +49,16 @@ return CommitsList.content.fadeTo('fast', 1.0); }, success: function(data) { + CommitsList.lastSearch = search; CommitsList.content.html(data.html); return history.replaceState({ page: commitsUrl // Change url so if user reload a page - search results are saved }, document.title, commitsUrl); }, + error: function() { + CommitsList.lastSearch = null; + }, dataType: "json" }); }; |