Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Schatz <jschatz@gitlab.com>2016-07-01 17:41:52 +0300
committerJacob Schatz <jschatz@gitlab.com>2016-07-01 17:41:52 +0300
commit6c0d3b4cf3847b78b89170ccb0d8a1e5ebdc48d6 (patch)
tree95686782137afba7fd0d60cda4239ade29b94e1d /app/assets
parentc578fb064c6a90cbaf60959d7706c0bcc34d87f5 (diff)
parentcc154fc47b4ae2c81d9b8d92d725b4a082ed7727 (diff)
Merge branch 'cache-autocomplete-results' into 'master'
Cache autocomplete results ## What does this MR do? Caches the results of the autocomplete AJAX call to stop new GFM inputs on the page from requesting new data. The cache is then cleared on each new page so that it doesn't stay around per project. See merge request !5043
Diffstat (limited to 'app/assets')
-rw-r--r--app/assets/javascripts/gfm_auto_complete.js.coffee7
1 files changed, 5 insertions, 2 deletions
diff --git a/app/assets/javascripts/gfm_auto_complete.js.coffee b/app/assets/javascripts/gfm_auto_complete.js.coffee
index 190bb38504c..b7d040bae85 100644
--- a/app/assets/javascripts/gfm_auto_complete.js.coffee
+++ b/app/assets/javascripts/gfm_auto_complete.js.coffee
@@ -4,7 +4,7 @@ window.GitLab ?= {}
GitLab.GfmAutoComplete =
dataLoading: false
dataLoaded: false
-
+ cachedData: {}
dataSource: ''
# Emoji
@@ -55,7 +55,7 @@ GitLab.GfmAutoComplete =
@setupAtWho()
if @dataSource
- if !@dataLoading
+ if not @dataLoading and not @cachedData
@dataLoading = true
# We should wait until initializations are done
@@ -70,6 +70,8 @@ GitLab.GfmAutoComplete =
@loadData(data)
, 1000)
+ if @cachedData?
+ @loadData(@cachedData)
setupAtWho: ->
# Emoji
@@ -205,6 +207,7 @@ GitLab.GfmAutoComplete =
$.getJSON(dataSource)
loadData: (data) ->
+ @cachedData = data
@dataLoaded = true
# load members